X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FRepository%2FTagRepository.php;h=5c45211f6beb1e2820e9ed5ddba79f95c10a04df;hb=2490f61dca635026a3eb9b5e9b6978b1981b1172;hp=213283e5d6d8b1da418a2eba536823fc152ec83e;hpb=4fc7eba34904a062cddf1e61956c48f27cb2e06c;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 213283e5..5c45211f 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -62,6 +62,27 @@ class TagRepository extends EntityRepository return $tags; } + /** + * Find all tags (flat) per user with nb entries. + * + * @param int $userId + * + * @return array + */ + public function findAllFlatTagsWithNbEntries($userId) + { + return $this->createQueryBuilder('t') + ->select('t.id, t.label, t.slug, count(e.id) as nbEntries') + ->distinct(true) + ->leftJoin('t.entries', 'e') + ->where('e.user = :userId') + ->groupBy('t.id') + ->orderBy('t.slug') + ->setParameter('userId', $userId) + ->getQuery() + ->getArrayResult(); + } + /** * Used only in test case to get a tag for our entry. *