]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/EntryRepository.php
Show untagged entries count on tag list
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / EntryRepository.php
index 47db4c079b83decc68e9b29b3cc0213838e0bf47..3a1f19b4ccad3adc761f6cff35c32c184859ce85 100644 (file)
@@ -115,6 +115,20 @@ class EntryRepository extends EntityRepository
             ->andWhere('size(e.tags) = 0');
     }
 
+    /**
+     * Retrieve the number of untagged entries for a user.
+     * 
+     * @param int $userId
+     * 
+     * @return int
+     */
+    public function countUntaggedEntriesByUser($userId)
+    {
+        return $this->getRawBuilderForUntaggedByUser($userId)
+            ->select('count(e.id)')
+            ->getSingleScalarResult();
+    }
+
     /**
      * Find Entries.
      *
@@ -151,7 +165,7 @@ class EntryRepository extends EntityRepository
             $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since)));
         }
 
-        if ('' !== $tags) {
+        if (is_string($tags) && '' !== $tags) {
             foreach (explode(',', $tags) as $i => $tag) {
                 $entryAlias = 'e' . $i;
                 $tagAlias = 't' . $i;
@@ -344,26 +358,6 @@ class EntryRepository extends EntityRepository
         return (int) $qb->getQuery()->getSingleScalarResult();
     }
 
-    /**
-     * Count all entries for a tag and a user.
-     *
-     * @param int $userId
-     * @param int $tagId
-     *
-     * @return int
-     */
-    public function countAllEntriesByUserIdAndTagId($userId, $tagId)
-    {
-        $qb = $this->createQueryBuilder('e')
-            ->select('count(e.id)')
-            ->leftJoin('e.tags', 't')
-            ->where('e.user = :userId')->setParameter('userId', $userId)
-            ->andWhere('t.id = :tagId')->setParameter('tagId', $tagId)
-        ;
-
-        return (int) $qb->getQuery()->getSingleScalarResult();
-    }
-
     /**
      * Remove all entries for a user id.
      * Used when a user want to reset all informations.