aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php4
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php33
2 files changed, 18 insertions, 19 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index ab50ebdf..dfb5eb54 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -251,7 +251,7 @@ class EntryController extends Controller
251 /** 251 /**
252 * Shows random entry depending on the given type. 252 * Shows random entry depending on the given type.
253 * 253 *
254 * @param Entry $entry 254 * @param string $type
255 * 255 *
256 * @Route("/{type}/random", name="random_entry", requirements={"_locale": "unread|starred|archive|untagged|all"}) 256 * @Route("/{type}/random", name="random_entry", requirements={"_locale": "unread|starred|archive|untagged|all"})
257 * 257 *
@@ -267,7 +267,7 @@ class EntryController extends Controller
267 $bag->clear(); 267 $bag->clear();
268 $bag->add('notice', 'flashes.entry.notice.no_random_entry'); 268 $bag->add('notice', 'flashes.entry.notice.no_random_entry');
269 269
270 return $this->redirect($this->generateUrl('homepage')); 270 return $this->redirect($this->generateUrl($type));
271 } 271 }
272 272
273 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); 273 return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
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