aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-07-30 09:41:51 +0200
committerJoas Schilling <coding@schilljs.com>2018-07-30 09:41:51 +0200
commit66945f95749adcb4670a82156edc376dc4aa5b93 (patch)
tree3ebd440527c0984030c3b4f1c074673b989b1c43 /lib/private/Comments
parent566800b29c3376ede04439a92545059146f99505 (diff)
downloadnextcloud-server-66945f95749adcb4670a82156edc376dc4aa5b93.tar.gz
nextcloud-server-66945f95749adcb4670a82156edc376dc4aa5b93.zip
Allow to filter the unread count by verb
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php9
1 files changed, 7 insertions, 2 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();