aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Repository/EntryRepository.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-10-12 22:13:33 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2018-10-12 22:14:12 +0200
commitc694f4b0eda024de041a606ce381eb92c5c6ff65 (patch)
tree712b446aec38f7f07826947057cdb76d7acf7e56 /src/Wallabag/CoreBundle/Repository/EntryRepository.php
parent60e919b8e218d118d04b797fc98cb2023a18e3b7 (diff)
downloadwallabag-c694f4b0eda024de041a606ce381eb92c5c6ff65.tar.gz
wallabag-c694f4b0eda024de041a606ce381eb92c5c6ff65.tar.zst
wallabag-c694f4b0eda024de041a606ce381eb92c5c6ff65.zip
Redirect to the current view instead of homepageadd-random-article
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