forked from wallabag/wallabag
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
This commit is contained in:
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user