diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 05563079..879e6671 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -435,7 +435,7 @@ class EntryRepository extends EntityRepository | |||
435 | * Returns a random entry, filtering by status. | 435 | * Returns a random entry, filtering by status. |
436 | * | 436 | * |
437 | * @param $userId | 437 | * @param $userId |
438 | * @param string $status can be unread, archive or starred | 438 | * @param string $type can be unread, archive, starred, etc |
439 | * | 439 | * |
440 | * @throws \Doctrine\ORM\NoResultException | 440 | * @throws \Doctrine\ORM\NoResultException |
441 | * @throws \Doctrine\ORM\NonUniqueResultException | 441 | * @throws \Doctrine\ORM\NonUniqueResultException |
@@ -444,26 +444,25 @@ class EntryRepository extends EntityRepository | |||
444 | * | 444 | * |
445 | * @return Entry | 445 | * @return Entry |
446 | */ | 446 | */ |
447 | public function getRandomEntry($userId, $status = '') | 447 | public function getRandomEntry($userId, $type = '') |
448 | { | 448 | { |
449 | $qb = $this->getQueryBuilderByUser($userId) | 449 | $qb = $this->getQueryBuilderByUser($userId) |
450 | ->select('MIN(e.id)', 'MAX(e.id)'); | 450 | ->select('MIN(e.id)', 'MAX(e.id)'); |
451 | 451 | ||
452 | if ('unread' === $status) { | 452 | switch ($type) { |
453 | $qb->andWhere('e.isArchived = false'); | 453 | case 'unread': |
454 | } | 454 | $qb->andWhere('e.isArchived = false'); |
455 | 455 | break; | |
456 | if ('archive' === $status) { | 456 | case 'archive': |
457 | $qb->andWhere('e.isArchived = true'); | 457 | $qb->andWhere('e.isArchived = true'); |
458 | } | 458 | break; |
459 | 459 | case 'starred': | |
460 | if ('starred' === $status) { | 460 | $qb->andWhere('e.isStarred = true'); |
461 | $qb->andWhere('e.isStarred = true'); | 461 | break; |
462 | } | 462 | case 'untagged': |
463 | 463 | $qb->leftJoin('e.tags', 't'); | |
464 | if ('untagged' === $status) { | 464 | $qb->andWhere('t.id is null'); |
465 | $qb->leftJoin('e.tags', 't'); | 465 | break; |
466 | $qb->andWhere('t.id is null'); | ||
467 | } | 466 | } |
468 | 467 | ||
469 | $idLimits = $qb | 468 | $idLimits = $qb |