aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Controller/TagController.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/Controller/TagController.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/Controller/TagController.php')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index c5746734..5acc6852 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -86,10 +86,25 @@ class TagController extends Controller
86 { 86 {
87 $tags = $this->getDoctrine() 87 $tags = $this->getDoctrine()
88 ->getRepository('WallabagCoreBundle:Tag') 88 ->getRepository('WallabagCoreBundle:Tag')
89 ->findAllTagsWithEntries($this->getUser()->getId()); 89 ->findAllTags($this->getUser()->getId());
90
91 $flatTags = [];
92
93 foreach ($tags as $key => $tag) {
94 $nbEntries = $this->getDoctrine()
95 ->getRepository('WallabagCoreBundle:Entry')
96 ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag['id']);
97
98 $flatTags[] = [
99 'id' => $tag['id'],
100 'label' => $tag['label'],
101 'slug' => $tag['slug'],
102 'nbEntries' => $nbEntries,
103 ];
104 }
90 105
91 return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ 106 return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [
92 'tags' => $tags, 107 'tags' => $flatTags,
93 ]); 108 ]);
94 } 109 }
95 110