aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 4d45e5f5..e5c21679 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -85,6 +85,22 @@ class EntryRepository extends EntityRepository
85 } 85 }
86 86
87 /** 87 /**
88 * Retrieves untagged entries for a user.
89 *
90 * @param int $userId
91 *
92 * @return QueryBuilder
93 */
94 public function getBuilderForUntaggedByUser($userId)
95 {
96 return $this
97 ->getBuilderByUser($userId)
98 ->leftJoin('e.tags', 't')
99 ->groupBy('e.id')
100 ->having('count(t.id) = 0');
101 }
102
103 /**
88 * Find Entries. 104 * Find Entries.
89 * 105 *
90 * @param int $userId 106 * @param int $userId
@@ -92,12 +108,15 @@ class EntryRepository extends EntityRepository
92 * @param bool $isStarred 108 * @param bool $isStarred
93 * @param string $sort 109 * @param string $sort
94 * @param string $order 110 * @param string $order
111 * @param int $since
112 * @param string $tags
95 * 113 *
96 * @return array 114 * @return array
97 */ 115 */
98 public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC') 116 public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '')
99 { 117 {
100 $qb = $this->createQueryBuilder('e') 118 $qb = $this->createQueryBuilder('e')
119 ->leftJoin('e.tags', 't')
101 ->where('e.user =:userId')->setParameter('userId', $userId); 120 ->where('e.user =:userId')->setParameter('userId', $userId);
102 121
103 if (null !== $isArchived) { 122 if (null !== $isArchived) {
@@ -108,6 +127,16 @@ class EntryRepository extends EntityRepository
108 $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred); 127 $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred);
109 } 128 }
110 129
130 if ($since >= 0) {
131 $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
132 }
133
134 if ('' !== $tags) {
135 foreach (explode(',', $tags) as $tag) {
136 $qb->andWhere('t.label = :label')->setParameter('label', $tag);
137 }
138 }
139
111 if ('created' === $sort) { 140 if ('created' === $sort) {
112 $qb->orderBy('e.id', $order); 141 $qb->orderBy('e.id', $order);
113 } elseif ('updated' === $sort) { 142 } elseif ('updated' === $sort) {
@@ -210,6 +239,19 @@ class EntryRepository extends EntityRepository
210 } 239 }
211 240
212 /** 241 /**
242 * Remove tags from all user entries.
243 *
244 * @param int $userId
245 * @param Array<Tag> $tags
246 */
247 public function removeTags($userId, $tags)
248 {
249 foreach ($tags as $tag) {
250 $this->removeTag($userId, $tag);
251 }
252 }
253
254 /**
213 * Find all entries that are attached to a give tag id. 255 * Find all entries that are attached to a give tag id.
214 * 256 *
215 * @param int $userId 257 * @param int $userId