aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:23:44 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:23:44 +0200
commit289875836a09944f5993d33753042abfef13809e (patch)
tree451f2c7ec7011f1f0ee8911fb1921b02f158e1dc /src/Wallabag/CoreBundle
parent82fc3290d4fec45ede270e2c1ad2079fe3020adc (diff)
downloadwallabag-289875836a09944f5993d33753042abfef13809e.tar.gz
wallabag-289875836a09944f5993d33753042abfef13809e.tar.zst
wallabag-289875836a09944f5993d33753042abfef13809e.zip
Fix tag count for PostgreSQL
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php10
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php4
2 files changed, 6 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index f5c4ea6a..9d127da7 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -7,17 +7,17 @@ use Doctrine\ORM\EntityRepository;
7class TagRepository extends EntityRepository 7class TagRepository extends EntityRepository
8{ 8{
9 /** 9 /**
10 * Find all tags per user. 10 * Count all tags per user.
11 * 11 *
12 * @param int $userId 12 * @param int $userId
13 * @param int $cacheLifeTime Duration of the cache for this query 13 * @param int $cacheLifeTime Duration of the cache for this query
14 * 14 *
15 * @return array 15 * @return int
16 */ 16 */
17 public function findAllTags($userId, $cacheLifeTime = null) 17 public function countAllTags($userId, $cacheLifeTime = null)
18 { 18 {
19 $query = $this->createQueryBuilder('t') 19 $query = $this->createQueryBuilder('t')
20 ->select('t') 20 ->select('t.slug')
21 ->leftJoin('t.entries', 'e') 21 ->leftJoin('t.entries', 'e')
22 ->where('e.user = :userId')->setParameter('userId', $userId) 22 ->where('e.user = :userId')->setParameter('userId', $userId)
23 ->groupBy('t.slug') 23 ->groupBy('t.slug')
@@ -29,7 +29,7 @@ class TagRepository extends EntityRepository
29 $query->setResultCacheLifetime($cacheLifeTime); 29 $query->setResultCacheLifetime($cacheLifeTime);
30 } 30 }
31 31
32 return $query->getArrayResult(); 32 return count($query->getArrayResult());
33 } 33 }
34 34
35 /** 35 /**
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index 45dc591d..fb4c7412 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -104,9 +104,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
104 return 0; 104 return 0;
105 } 105 }
106 106
107 $data = $this->tagRepository->findAllTags($user->getId()); 107 return $this->tagRepository->countAllTags($user->getId());
108
109 return count($data);
110 } 108 }
111 109
112 public function getName() 110 public function getName()