From 935e9fffb4083f83e86c4e97a32bc2d9bccd677f Mon Sep 17 00:00:00 2001 From: Nicolas Hart Date: Sun, 6 Aug 2017 21:58:14 +0200 Subject: Reduce number of queries on tag list --- .../CoreBundle/Controller/TagController.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/Wallabag/CoreBundle/Controller') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index f2ca58c6..be2dff98 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -84,28 +84,11 @@ class TagController extends Controller */ public function showTagAction() { - $repository = $this->get('wallabag_core.entry_repository'); $tags = $this->get('wallabag_core.tag_repository') - ->findAllTags($this->getUser()->getId()); - - $flatTags = []; - - foreach ($tags as $tag) { - $nbEntries = $repository->countAllEntriesByUserIdAndTagId( - $this->getUser()->getId(), - $tag->getId() - ); - - $flatTags[] = [ - 'id' => $tag->getId(), - 'label' => $tag->getLabel(), - 'slug' => $tag->getSlug(), - 'nbEntries' => $nbEntries, - ]; - } + ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ - 'tags' => $flatTags, + 'tags' => $tags, ]); } -- cgit v1.2.3