diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 20 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/TagRepository.php | 10 |
2 files changed, 27 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 75127b7d..cd2b47b9 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -309,4 +309,24 @@ class EntryRepository extends EntityRepository | |||
309 | 309 | ||
310 | return $qb->getQuery()->getSingleScalarResult(); | 310 | return $qb->getQuery()->getSingleScalarResult(); |
311 | } | 311 | } |
312 | |||
313 | /** | ||
314 | * Count all entries for a tag and a user. | ||
315 | * | ||
316 | * @param int $userId | ||
317 | * @param int $tagId | ||
318 | * | ||
319 | * @return int | ||
320 | */ | ||
321 | public function countAllEntriesByUserIdAndTagId($userId, $tagId) | ||
322 | { | ||
323 | $qb = $this->createQueryBuilder('e') | ||
324 | ->select('count(e.id)') | ||
325 | ->leftJoin('e.tags', 't') | ||
326 | ->where('e.user=:userId')->setParameter('userId', $userId) | ||
327 | ->andWhere('t.id=:tagId')->setParameter('tagId', $tagId) | ||
328 | ; | ||
329 | |||
330 | return $qb->getQuery()->getSingleScalarResult(); | ||
331 | } | ||
312 | } | 332 | } |
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 9d127da7..e76878d4 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php | |||
@@ -33,19 +33,23 @@ class TagRepository extends EntityRepository | |||
33 | } | 33 | } |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Find all tags with associated entries per user. | 36 | * Find all tags per user. |
37 | * | 37 | * |
38 | * @param int $userId | 38 | * @param int $userId |
39 | * | 39 | * |
40 | * @return array | 40 | * @return array |
41 | */ | 41 | */ |
42 | public function findAllTagsWithEntries($userId) | 42 | public function findAllTags($userId) |
43 | { | 43 | { |
44 | return $this->createQueryBuilder('t') | 44 | return $this->createQueryBuilder('t') |
45 | ->select('t.slug', 't.label', 't.id') | ||
45 | ->leftJoin('t.entries', 'e') | 46 | ->leftJoin('t.entries', 'e') |
46 | ->where('e.user = :userId')->setParameter('userId', $userId) | 47 | ->where('e.user = :userId')->setParameter('userId', $userId) |
48 | ->groupBy('t.slug') | ||
49 | ->addGroupBy('t.label') | ||
50 | ->addGroupBy('t.id') | ||
47 | ->getQuery() | 51 | ->getQuery() |
48 | ->getResult(); | 52 | ->getArrayResult(); |
49 | } | 53 | } |
50 | 54 | ||
51 | /** | 55 | /** |