aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/TagController.php
diff options
context:
space:
mode:
authorNicolas Hart <contact@nclshart.net>2017-08-06 21:58:14 +0200
committerNicolas Hart <contact@nclshart.net>2017-08-06 23:02:32 +0200
commit935e9fffb4083f83e86c4e97a32bc2d9bccd677f (patch)
treef4607a17b6d6bf27bcc3e7f232ac692b1e3dece7 /src/Wallabag/CoreBundle/Controller/TagController.php
parentf11a3cf21ca77f16b5dff3a6d015f2043317c596 (diff)
downloadwallabag-935e9fffb4083f83e86c4e97a32bc2d9bccd677f.tar.gz
wallabag-935e9fffb4083f83e86c4e97a32bc2d9bccd677f.tar.zst
wallabag-935e9fffb4083f83e86c4e97a32bc2d9bccd677f.zip
Reduce number of queries on tag list
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/TagController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php21
1 files changed, 2 insertions, 19 deletions
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
84 */ 84 */
85 public function showTagAction() 85 public function showTagAction()
86 { 86 {
87 $repository = $this->get('wallabag_core.entry_repository');
88 $tags = $this->get('wallabag_core.tag_repository') 87 $tags = $this->get('wallabag_core.tag_repository')
89 ->findAllTags($this->getUser()->getId()); 88 ->findAllFlatTagsWithNbEntries($this->getUser()->getId());
90
91 $flatTags = [];
92
93 foreach ($tags as $tag) {
94 $nbEntries = $repository->countAllEntriesByUserIdAndTagId(
95 $this->getUser()->getId(),
96 $tag->getId()
97 );
98
99 $flatTags[] = [
100 'id' => $tag->getId(),
101 'label' => $tag->getLabel(),
102 'slug' => $tag->getSlug(),
103 'nbEntries' => $nbEntries,
104 ];
105 }
106 89
107 return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ 90 return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [
108 'tags' => $flatTags, 91 'tags' => $tags,
109 ]); 92 ]);
110 } 93 }
111 94