diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 655217c95..ca9ff56f3 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -675,9 +675,6 @@ class EntryController extends AbstractController } } - $nbEntriesUntagged = $this->entryRepository - ->countUntaggedEntriesByUser($this->getUser()->getId()); - return $this->render( '@WallabagCore/Entry/entries.html.twig', [ 'form' => $form->createView(), @@ -685,7 +682,6 @@ class EntryController extends AbstractController 'currentPage' => $page, 'searchTerm' => $searchTerm, 'isFiltered' => $form->isSubmitted(), - 'nbEntriesUntagged' => $nbEntriesUntagged, ] ); } diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 9dded5e57..3e0b4effd 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -37,6 +37,20 @@ class EntryRepository extends ServiceEntityRepository ; } + /** + * Retrieves all entries count for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getCountBuilderForAllByUser($userId) + { + return $this + ->getQueryBuilderByUser($userId) + ; + } + /** * Retrieves unread entries for a user. * @@ -52,6 +66,21 @@ class EntryRepository extends ServiceEntityRepository ; } + /** + * Retrieves unread entries count for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getCountBuilderForUnreadByUser($userId) + { + return $this + ->getQueryBuilderByUser($userId) + ->andWhere('e.isArchived = false') + ; + } + /** * Retrieves entries with the same domain. * @@ -94,6 +123,21 @@ class EntryRepository extends ServiceEntityRepository ; } + /** + * Retrieves read entries count for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getCountBuilderForArchiveByUser($userId) + { + return $this + ->getQueryBuilderByUser($userId) + ->andWhere('e.isArchived = true') + ; + } + /** * Retrieves starred entries for a user. * @@ -109,6 +153,21 @@ class EntryRepository extends ServiceEntityRepository ; } + /** + * Retrieves starred entries count for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getCountBuilderForStarredByUser($userId) + { + return $this + ->getQueryBuilderByUser($userId) + ->andWhere('e.isStarred = true') + ; + } + /** * Retrieves entries filtered with a search term for a user. * @@ -167,6 +226,21 @@ class EntryRepository extends ServiceEntityRepository ; } + /** + * Retrieve entries with annotations count for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getCountBuilderForAnnotationsByUser($userId) + { + return $this + ->getQueryBuilderByUser($userId) + ->innerJoin('e.annotations', 'a') + ; + } + /** * Retrieve untagged entries for a user. * @@ -563,6 +637,23 @@ class EntryRepository extends ServiceEntityRepository return $qb->getQuery()->getArrayResult(); } + /** + * @param int $userId + * + * @return array + */ + public function findEmptyEntriesIdByUserId($userId = null) + { + $qb = $this->createQueryBuilder('e') + ->select('e.id'); + + if (null !== $userId) { + $qb->where('e.user = :userid AND e.content IS NULL')->setParameter(':userid', $userId); + } + + return $qb->getQuery()->getArrayResult(); + } + /** * Find all entries by url and owner. * diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig index f3f1488a8..7f1f2592d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig @@ -118,9 +118,9 @@