- $max = $this->getEntityManager()
- ->createQuery('SELECT MAX(e.id) FROM Wallabag\CoreBundle\Entity\Entry e WHERE e.user = :userId')
- ->setParameter('userId', $userId)
- ->getSingleScalarResult();
-
- $qb = $this->createQueryBuilder('e')
- ->where('e.user = :user_id')->setParameter('user_id', $userId);
-
- if ('unread' === $status) {
- $qb->andWhere('e.isArchived = false');
+ $qb = $this->getQueryBuilderByUser($userId)
+ ->select('MIN(e.id)', 'MAX(e.id)');
+
+ switch ($type) {
+ case 'unread':
+ $qb->andWhere('e.isArchived = false');
+ break;
+ case 'archive':
+ $qb->andWhere('e.isArchived = true');
+ break;
+ case 'starred':
+ $qb->andWhere('e.isStarred = true');
+ break;
+ case 'untagged':
+ $qb->leftJoin('e.tags', 't');
+ $qb->andWhere('t.id is null');
+ break;