mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-21 18:11:10 +00:00
Reduce number of queries on tag list
This commit is contained in:
parent
f11a3cf21c
commit
935e9fffb4
3 changed files with 23 additions and 39 deletions
|
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue