summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-07-31 12:05:52 +0200
committerGitHub <noreply@github.com>2018-07-31 12:05:52 +0200
commitc39bc1638b812ef9660cfdb0ab6ca58d70ad68d8 (patch)
tree89d02b4ccbb646b253fdad1155a68ffe31530528 /lib
parentef85ef07863cb6aa385d571eaee9037448f8520d (diff)
parent66945f95749adcb4670a82156edc376dc4aa5b93 (diff)
downloadnextcloud-server-c39bc1638b812ef9660cfdb0ab6ca58d70ad68d8.tar.gz
nextcloud-server-c39bc1638b812ef9660cfdb0ab6ca58d70ad68d8.zip
Merge pull request #10444 from nextcloud/feature/noid/allow-to-filter-unread-count-by-verb
Allow to filter the unread count by verb
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Comments/Manager.php9
-rw-r--r--lib/public/Comments/ICommentsManager.php3
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 8f76d49b192..6d9e37ae94e 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -546,12 +546,13 @@ class Manager implements ICommentsManager {
* @param $objectId string the id of the object
* @param \DateTime $notOlderThan optional, timestamp of the oldest comments
* that may be returned
+ * @param string $verb Limit the verb of the comment - Added in 14.0.0
* @return Int
* @since 9.0.0
*/
- public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null) {
+ public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '') {
$qb = $this->dbConn->getQueryBuilder();
- $query = $qb->select($qb->createFunction('COUNT(`id`)'))
+ $query = $qb->select($qb->createFunction('COUNT(' . $qb->getColumnName('id') . ')'))
->from('comments')
->where($qb->expr()->eq('object_type', $qb->createParameter('type')))
->andWhere($qb->expr()->eq('object_id', $qb->createParameter('id')))
@@ -564,6 +565,10 @@ class Manager implements ICommentsManager {
->setParameter('notOlderThan', $notOlderThan, 'datetime');
}
+ if ($verb !== '') {
+ $query->andWhere($qb->expr()->eq('verb', $qb->createNamedParameter($verb)));
+ }
+
$resultStatement = $query->execute();
$data = $resultStatement->fetch(\PDO::FETCH_NUM);
$resultStatement->closeCursor();
diff --git a/lib/public/Comments/ICommentsManager.php b/lib/public/Comments/ICommentsManager.php
index ca98214cd72..744263643ec 100644
--- a/lib/public/Comments/ICommentsManager.php
+++ b/lib/public/Comments/ICommentsManager.php
@@ -157,10 +157,11 @@ interface ICommentsManager {
* @param $objectId string the id of the object
* @param \DateTime|null $notOlderThan optional, timestamp of the oldest comments
* that may be returned
+ * @param string $verb Limit the verb of the comment - Added in 14.0.0
* @return Int
* @since 9.0.0
*/
- public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null);
+ public function getNumberOfCommentsForObject($objectType, $objectId, \DateTime $notOlderThan = null, $verb = '');
/**
* Get the number of unread comments for all files in a folder