]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Controller/TagController.php
Optimize the way tag list is rendered
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Controller / TagController.php
index c5746734d398fd2653a64ade83d66d150acbbafe..5acc685281a205a57cf88b92e72125cc040abc0b 100644 (file)
@@ -86,10 +86,25 @@ class TagController extends Controller
     {
         $tags = $this->getDoctrine()
             ->getRepository('WallabagCoreBundle:Tag')
-            ->findAllTagsWithEntries($this->getUser()->getId());
+            ->findAllTags($this->getUser()->getId());
+
+        $flatTags = [];
+
+        foreach ($tags as $key => $tag) {
+            $nbEntries = $this->getDoctrine()
+                ->getRepository('WallabagCoreBundle:Entry')
+                ->countAllEntriesByUserIdAndTagId($this->getUser()->getId(), $tag['id']);
+
+            $flatTags[] = [
+                'id' => $tag['id'],
+                'label' => $tag['label'],
+                'slug' => $tag['slug'],
+                'nbEntries' => $nbEntries,
+            ];
+        }
 
         return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [
-            'tags' => $tags,
+            'tags' => $flatTags,
         ]);
     }