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.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 6941eaee..702646fe 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -431,7 +431,7 @@ class EntryRepository extends EntityRepository
431 * Returns a random entry, filtering by status. 431 * Returns a random entry, filtering by status.
432 * 432 *
433 * @param $userId 433 * @param $userId
434 * @param string $status can be unread, archive or starred 434 * @param string $type can be unread, archive, starred, etc
435 * 435 *
436 * @throws \Doctrine\ORM\NoResultException 436 * @throws \Doctrine\ORM\NoResultException
437 * @throws \Doctrine\ORM\NonUniqueResultException 437 * @throws \Doctrine\ORM\NonUniqueResultException
@@ -440,26 +440,25 @@ class EntryRepository extends EntityRepository
440 * 440 *
441 * @return Entry 441 * @return Entry
442 */ 442 */
443 public function getRandomEntry($userId, $status = '') 443 public function getRandomEntry($userId, $type = '')
444 { 444 {
445 $qb = $this->getQueryBuilderByUser($userId) 445 $qb = $this->getQueryBuilderByUser($userId)
446 ->select('MIN(e.id)', 'MAX(e.id)'); 446 ->select('MIN(e.id)', 'MAX(e.id)');
447 447
448 if ('unread' === $status) { 448 switch ($type) {
449 $qb->andWhere('e.isArchived = false'); 449 case 'unread':
450 } 450 $qb->andWhere('e.isArchived = false');
451 451 break;
452 if ('archive' === $status) { 452 case 'archive':
453 $qb->andWhere('e.isArchived = true'); 453 $qb->andWhere('e.isArchived = true');
454 } 454 break;
455 455 case 'starred':
456 if ('starred' === $status) { 456 $qb->andWhere('e.isStarred = true');
457 $qb->andWhere('e.isStarred = true'); 457 break;
458 } 458 case 'untagged':
459 459 $qb->leftJoin('e.tags', 't');
460 if ('untagged' === $status) { 460 $qb->andWhere('t.id is null');
461 $qb->leftJoin('e.tags', 't'); 461 break;
462 $qb->andWhere('t.id is null');
463 } 462 }
464 463
465 $idLimits = $qb 464 $idLimits = $qb