aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php8
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php20
2 files changed, 28 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 9325d261..1f22e901 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -371,4 +371,12 @@ class EntryRepository extends EntityRepository
371 ->setParameter('userId', $userId) 371 ->setParameter('userId', $userId)
372 ->execute(); 372 ->execute();
373 } 373 }
374
375 public function removeArchivedByUserId($userId)
376 {
377 $this->getEntityManager()
378 ->createQuery('DELETE FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = :userId AND e.isArchived = TRUE')
379 ->setParameter('userId', $userId)
380 ->execute();
381 }
374} 382}
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index 2182df25..b78e244e 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -76,4 +76,24 @@ class TagRepository extends EntityRepository
76 ->getQuery() 76 ->getQuery()
77 ->getSingleResult(); 77 ->getSingleResult();
78 } 78 }
79
80 public function findTagsForArchivedArticles($userId)
81 {
82 $ids = $this->createQueryBuilder('t')
83 ->select('t.id')
84 ->leftJoin('t.entries', 'e')
85 ->where('e.user = :userId')->setParameter('userId', $userId)
86 ->andWhere('e.isArchived = true')
87 ->groupBy('t.id')
88 ->orderBy('t.slug')
89 ->getQuery()
90 ->getArrayResult();
91
92 $tags = [];
93 foreach ($ids as $id) {
94 $tags[] = $this->find($id);
95 }
96
97 return $tags;
98 }
79} 99}