aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/TagRepository.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-08-08 19:48:47 +0200
committerGitHub <noreply@github.com>2017-08-08 19:48:47 +0200
commit86ecd2b543e0f63609213ff45665fef94e38c681 (patch)
treebbd2709f61167882ca2b023ade4f037d249fd2b8 /src/Wallabag/CoreBundle/Repository/TagRepository.php
parentaff1dd4ff13f541001832cfb009d6f8854ff978d (diff)
parent935e9fffb4083f83e86c4e97a32bc2d9bccd677f (diff)
downloadwallabag-86ecd2b543e0f63609213ff45665fef94e38c681.tar.gz
wallabag-86ecd2b543e0f63609213ff45665fef94e38c681.tar.zst
wallabag-86ecd2b543e0f63609213ff45665fef94e38c681.zip
Merge pull request #3314 from nclsHart/fix-3313
Reduce number of queries on tag list
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/TagRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php21
1 files changed, 21 insertions, 0 deletions
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
@@ -63,6 +63,27 @@ class TagRepository extends EntityRepository
63 } 63 }
64 64
65 /** 65 /**
66 * Find all tags (flat) per user with nb entries.
67 *
68 * @param int $userId
69 *
70 * @return array
71 */
72 public function findAllFlatTagsWithNbEntries($userId)
73 {
74 return $this->createQueryBuilder('t')
75 ->select('t.id, t.label, t.slug, count(e.id) as nbEntries')
76 ->distinct(true)
77 ->leftJoin('t.entries', 'e')
78 ->where('e.user = :userId')
79 ->groupBy('t.id')
80 ->orderBy('t.slug')
81 ->setParameter('userId', $userId)
82 ->getQuery()
83 ->getArrayResult();
84 }
85
86 /**
66 * Used only in test case to get a tag for our entry. 87 * Used only in test case to get a tag for our entry.
67 * 88 *
68 * @return Tag 89 * @return Tag