From e5fb89e5d31c1c0645e8dd252bb4f970dc5f3226 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 25 Jun 2016 21:05:50 +0200 Subject: Add since parameter --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 4d45e5f5..4b607c81 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -95,7 +95,7 @@ class EntryRepository extends EntityRepository * * @return array */ - public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC') + public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0) { $qb = $this->createQueryBuilder('e') ->where('e.user =:userId')->setParameter('userId', $userId); @@ -108,6 +108,10 @@ class EntryRepository extends EntityRepository $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred); } + if ($since >= 0) { + $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); + } + if ('created' === $sort) { $qb->orderBy('e.id', $order); } elseif ('updated' === $sort) { -- cgit v1.2.3 From 28803f106bd091b5a7540a134cba2545d12d25ea Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 25 Jun 2016 16:27:38 +0200 Subject: Add filter for tags on API --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 4b607c81..8d2ec9ce 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -95,9 +95,10 @@ class EntryRepository extends EntityRepository * * @return array */ - public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0) + public function findEntries($userId, $isArchived = null, $isStarred = null, $sort = 'created', $order = 'ASC', $since = 0, $tags = '') { $qb = $this->createQueryBuilder('e') + ->leftJoin('e.tags', 't') ->where('e.user =:userId')->setParameter('userId', $userId); if (null !== $isArchived) { @@ -110,6 +111,11 @@ class EntryRepository extends EntityRepository if ($since >= 0) { $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); + + if ('' !== $tags) { + foreach (explode(',', $tags) as $tag) { + $qb->andWhere('t.label = :label')->setParameter('label', $tag); + } } if ('created' === $sort) { -- cgit v1.2.3 From 4f0558a0d43b3d0bbd661c06568257a91836fa91 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 29 Jun 2016 20:52:37 +0200 Subject: fix merge issue --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 8d2ec9ce..b543c5ae 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -111,7 +111,8 @@ class EntryRepository extends EntityRepository if ($since >= 0) { $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); - + } + if ('' !== $tags) { foreach (explode(',', $tags) as $tag) { $qb->andWhere('t.label = :label')->setParameter('label', $tag); -- cgit v1.2.3 From 8cb869ea9556e84c07c9606c9c65432b70f522fd Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 24 Jul 2016 11:47:03 +0200 Subject: add some missing phpdoc parameters --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index b543c5ae..e9351d85 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -92,6 +92,8 @@ class EntryRepository extends EntityRepository * @param bool $isStarred * @param string $sort * @param string $order + * @param int $since + * @param string $tags * * @return array */ -- cgit v1.2.3 From 4da01f492b20312461d3f4f612a98e3b52c76fa9 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 25 Jun 2016 18:37:41 +0200 Subject: Delete tag or tags by label Tests not included --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index e9351d85..63c4c3be 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -222,6 +222,19 @@ class EntryRepository extends EntityRepository $this->getEntityManager()->flush(); } + /** + * Remove tags from all user entries + * + * @param int $userId + * @param Array $tags + */ + + public function removeTags($userId, $tags) { + foreach ($tags as $tag) { + $this->removeTag($userId, $tag); + } + } + /** * Find all entries that are attached to a give tag id. * -- cgit v1.2.3 From 9bf83f1fb8d588b871a5d12289179de087756d02 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 25 Jun 2016 19:25:50 +0200 Subject: CS --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 63c4c3be..fada40bb 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -223,13 +223,13 @@ class EntryRepository extends EntityRepository } /** - * Remove tags from all user entries + * Remove tags from all user entries. * - * @param int $userId + * @param int $userId * @param Array $tags */ - - public function removeTags($userId, $tags) { + public function removeTags($userId, $tags) + { foreach ($tags as $tag) { $this->removeTag($userId, $tag); } -- cgit v1.2.3 From b6520f0b15ac35215e2d94d16a31ea971874dce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 26 Aug 2016 16:55:41 +0200 Subject: Add untagged entries Fix #1631 --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index fada40bb..e5c21679 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -84,6 +84,22 @@ class EntryRepository extends EntityRepository ; } + /** + * Retrieves untagged entries for a user. + * + * @param int $userId + * + * @return QueryBuilder + */ + public function getBuilderForUntaggedByUser($userId) + { + return $this + ->getBuilderByUser($userId) + ->leftJoin('e.tags', 't') + ->groupBy('e.id') + ->having('count(t.id) = 0'); + } + /** * Find Entries. * -- cgit v1.2.3 From 0b0233b1ec8208be47c76856a4e317673927b21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 1 Sep 2016 20:20:12 +0200 Subject: Enable cache for queries --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index e9351d85..86bce545 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -3,6 +3,7 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Query; use Pagerfanta\Adapter\DoctrineORMAdapter; use Pagerfanta\Pagerfanta; use Wallabag\CoreBundle\Entity\Tag; @@ -279,4 +280,20 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getSingleScalarResult(); } + + /** + * Enable cache for a query + * + * @param Query $query + * + * @return Query + */ + public function enableCache(Query $query) + { + $query->useQueryCache(true); + $query->useResultCache(true); + $query->setResultCacheLifetime(5); + + return $query; + } } -- cgit v1.2.3 From b3f4a11a81b520b8dcc2bcebeeafea2cc0338a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Sep 2016 14:02:50 +0200 Subject: Store cache lifetime in config --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 86bce545..4b205f6e 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -10,6 +10,8 @@ use Wallabag\CoreBundle\Entity\Tag; class EntryRepository extends EntityRepository { + private $lifeTime; + /** * Return a query builder to used by other getBuilderFor* method. * @@ -281,8 +283,13 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getSingleScalarResult(); } + public function setLifeTime($lifeTime) + { + $this->lifeTime = $lifeTime; + } + /** - * Enable cache for a query + * Enable cache for a query. * * @param Query $query * @@ -292,7 +299,7 @@ class EntryRepository extends EntityRepository { $query->useQueryCache(true); $query->useResultCache(true); - $query->setResultCacheLifetime(5); + $query->setResultCacheLifetime($this->lifeTime); return $query; } -- cgit v1.2.3 From 429d86f388da856c9d8d9a649147c5212bee4258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 4 Sep 2016 20:53:28 +0200 Subject: Added tags counter in sidebar (material theme) --- .../CoreBundle/Repository/EntryRepository.php | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 24d1a57a..719803a1 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -311,25 +311,4 @@ class EntryRepository extends EntityRepository return $qb->getQuery()->getSingleScalarResult(); } - - public function setLifeTime($lifeTime) - { - $this->lifeTime = $lifeTime; - } - - /** - * Enable cache for a query. - * - * @param Query $query - * - * @return Query - */ - public function enableCache(Query $query) - { - $query->useQueryCache(true); - $query->useResultCache(true); - $query->setResultCacheLifetime($this->lifeTime); - - return $query; - } } -- cgit v1.2.3 From a1d22ea7d0cc8c51ca5480aa41488f2c6373f1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 5 Sep 2016 10:23:40 +0200 Subject: Remove useless variable --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 719803a1..302e5a53 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -10,8 +10,6 @@ use Wallabag\CoreBundle\Entity\Tag; class EntryRepository extends EntityRepository { - private $lifeTime; - /** * Return a query builder to used by other getBuilderFor* method. * -- cgit v1.2.3 From 19ca0b2f355a657dd296bfa782473ffd45280572 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 1 Oct 2016 17:57:38 +0200 Subject: Avoid duplicate url with accents --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 302e5a53..1b023e96 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -281,7 +281,7 @@ class EntryRepository extends EntityRepository public function findByUrlAndUserId($url, $userId) { $res = $this->createQueryBuilder('e') - ->where('e.url = :url')->setParameter('url', $url) + ->where('e.url = :url')->setParameter('url', urldecode($url)) ->andWhere('e.user = :user_id')->setParameter('user_id', $userId) ->getQuery() ->getResult(); -- cgit v1.2.3 From c3f8b428dd50578a6eba5f4673ea1c9edabd2512 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 2 Oct 2016 15:41:08 +0200 Subject: Fix parameters in API _links We forgot to pass them to the factory --- src/Wallabag/CoreBundle/Repository/EntryRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 1b023e96..75127b7d 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -128,7 +128,7 @@ class EntryRepository extends EntityRepository $qb->andWhere('e.isStarred =:isStarred')->setParameter('isStarred', (bool) $isStarred); } - if ($since >= 0) { + if ($since > 0) { $qb->andWhere('e.updatedAt > :since')->setParameter('since', new \DateTime(date('Y-m-d H:i:s', $since))); } -- cgit v1.2.3 From 28bb48905a2104adad65508f51737f987dc1ad4c Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 9 Oct 2016 18:41:19 +0200 Subject: Optimize the way tag list is rendered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of retrieve all informations about entries of a tag to just count them, we’ll count them before with a fastest query. Also change the layout of the tag list in material design --- .../CoreBundle/Repository/EntryRepository.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Wallabag/CoreBundle/Repository/EntryRepository.php') diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 75127b7d..cd2b47b9 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -309,4 +309,24 @@ class EntryRepository extends EntityRepository return $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 $qb->getQuery()->getSingleScalarResult(); + } } -- cgit v1.2.3