mirror of
https://github.com/wallabag/wallabag.git
synced 2024-09-29 06:42:07 +00:00
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>
This commit is contained in:
parent
b7c5fda512
commit
0636697289
1 changed files with 16 additions and 3 deletions
|
@ -102,7 +102,7 @@ class EntryRepository extends EntityRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves untagged entries for a user.
|
* Retrieve a sorted list of untagged entries for a user.
|
||||||
*
|
*
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
*
|
*
|
||||||
|
@ -111,8 +111,21 @@ class EntryRepository extends EntityRepository
|
||||||
public function getBuilderForUntaggedByUser($userId)
|
public function getBuilderForUntaggedByUser($userId)
|
||||||
{
|
{
|
||||||
return $this
|
return $this
|
||||||
->getSortedQueryBuilderByUser($userId)
|
->sortQueryBuilder($this->getRawBuilderForUntaggedByUser($userId));
|
||||||
->andWhere('size(e.tags) = 0');
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve untagged entries for a user.
|
||||||
|
*
|
||||||
|
* @param int $userId
|
||||||
|
*
|
||||||
|
* @return QueryBuilder
|
||||||
|
*/
|
||||||
|
public function getRawBuilderForUntaggedByUser($userId)
|
||||||
|
{
|
||||||
|
return $this->getQueryBuilderByUser($userId)
|
||||||
|
->leftJoin('e.tags', 't')
|
||||||
|
->andWhere('t.id is null');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue