From: Kevin Decherf Date: Sun, 2 Sep 2018 14:43:49 +0000 (+0200) Subject: Show untagged entries count on tag list X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=86fd3da135d9ca2241dc09680d5dac1dd57fc707 Show untagged entries count on tag list Closes #3235 Signed-off-by: Kevin Decherf --- diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index 616c37f2..bc794c7f 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -86,9 +86,12 @@ class TagController extends Controller { $tags = $this->get('wallabag_core.tag_repository') ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); + $untagged = $this->get('wallabag_core.entry_repository') + ->countUntaggedEntriesForUser($this->getUser()->getId()); return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ 'tags' => $tags, + 'untagged' => $untagged ]); } diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index b5e35eff..3a1f19b4 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -115,6 +115,20 @@ class EntryRepository extends EntityRepository ->andWhere('size(e.tags) = 0'); } + /** + * Retrieve the number of untagged entries for a user. + * + * @param int $userId + * + * @return int + */ + public function countUntaggedEntriesByUser($userId) + { + return $this->getRawBuilderForUntaggedByUser($userId) + ->select('count(e.id)') + ->getSingleScalarResult(); + } + /** * Find Entries. * diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig index 070d5629..e428ddf9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig @@ -19,6 +19,6 @@
- {{ 'tag.list.see_untagged_entries'|trans }} + {{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})
{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig index c15b5146..6a8272fe 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig @@ -23,6 +23,6 @@
- {{ 'tag.list.see_untagged_entries'|trans }} + {{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})
{% endblock %}