aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2018-09-02 17:44:19 +0200
committerKevin Decherf <kevin@kdecherf.com>2018-09-05 18:44:08 +0200
commit0636697289b7ad50bfaa33c93ce4593543d435b5 (patch)
tree14082e04c069e42e478c507c1f847655db8aeb46 /src/Wallabag
parentb7c5fda512f29c99db69cb090fafb6f79abf6004 (diff)
downloadwallabag-0636697289b7ad50bfaa33c93ce4593543d435b5.tar.gz
wallabag-0636697289b7ad50bfaa33c93ce4593543d435b5.tar.zst
wallabag-0636697289b7ad50bfaa33c93ce4593543d435b5.zip
EntryRepository: refactor getBuilderForUntaggedByUser
Improve SQL performance by replacing size(e.tags) with a left join and a null condition Move the QueryBuilder logic into getRawBuilderForUntaggedByUser Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 749d2338..a31f97b5 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -102,7 +102,7 @@ class EntryRepository extends EntityRepository
102 } 102 }
103 103
104 /** 104 /**
105 * Retrieves untagged entries for a user. 105 * Retrieve a sorted list of untagged entries for a user.
106 * 106 *
107 * @param int $userId 107 * @param int $userId
108 * 108 *
@@ -111,8 +111,21 @@ class EntryRepository extends EntityRepository
111 public function getBuilderForUntaggedByUser($userId) 111 public function getBuilderForUntaggedByUser($userId)
112 { 112 {
113 return $this 113 return $this
114 ->getSortedQueryBuilderByUser($userId) 114 ->sortQueryBuilder($this->getRawBuilderForUntaggedByUser($userId));
115 ->andWhere('size(e.tags) = 0'); 115 }
116
117 /**
118 * Retrieve untagged entries for a user.
119 *
120 * @param int $userId
121 *
122 * @return QueryBuilder
123 */
124 public function getRawBuilderForUntaggedByUser($userId)
125 {
126 return $this->getQueryBuilderByUser($userId)
127 ->leftJoin('e.tags', 't')
128 ->andWhere('t.id is null');
116 } 129 }
117 130
118 /** 131 /**