aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-09 18:41:19 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-09 18:55:22 +0200
commit28bb48905a2104adad65508f51737f987dc1ad4c (patch)
tree41922f46efae593fc786b561486a40ee70e25383 /src/Wallabag/CoreBundle/Repository/EntryRepository.php
parentb4fcd60e7f217bf0b23fa99c83698e7407bee54b (diff)
downloadwallabag-28bb48905a2104adad65508f51737f987dc1ad4c.tar.gz
wallabag-28bb48905a2104adad65508f51737f987dc1ad4c.tar.zst
wallabag-28bb48905a2104adad65508f51737f987dc1ad4c.zip
Optimize the way tag list is rendered
Instead of retrieve all informations about entries of a tag to just count them, we’ll count them before with a fastest query. Also change the layout of the tag list in material design
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 75127b7d..cd2b47b9 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -309,4 +309,24 @@ class EntryRepository extends EntityRepository
309 309
310 return $qb->getQuery()->getSingleScalarResult(); 310 return $qb->getQuery()->getSingleScalarResult();
311 } 311 }
312
313 /**
314 * Count all entries for a tag and a user.
315 *
316 * @param int $userId
317 * @param int $tagId
318 *
319 * @return int
320 */
321 public function countAllEntriesByUserIdAndTagId($userId, $tagId)
322 {
323 $qb = $this->createQueryBuilder('e')
324 ->select('count(e.id)')
325 ->leftJoin('e.tags', 't')
326 ->where('e.user=:userId')->setParameter('userId', $userId)
327 ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId)
328 ;
329
330 return $qb->getQuery()->getSingleScalarResult();
331 }
312} 332}