aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-04-23 14:58:43 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-07-25 18:53:45 +0200
commitac2314e3d0e195b2af06473a6acfa5f76534cd63 (patch)
treed028b627370a2d98f2978f805057740014ebd911 /lib/private/Comments
parent1e16f7ecd9f6aa28af73545b4a53feeae2f8056d (diff)
downloadnextcloud-server-ac2314e3d0e195b2af06473a6acfa5f76534cd63.tar.gz
nextcloud-server-ac2314e3d0e195b2af06473a6acfa5f76534cd63.zip
Add pagination support
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index a06a2a0ec59..8f76d49b192 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -500,9 +500,11 @@ class Manager implements ICommentsManager {
* @param string $objectType Limit the search by object type
* @param string $objectId Limit the search by object id
* @param string $verb Limit the verb of the comment
+ * @param int $offset
+ * @param int $limit
* @return IComment[]
*/
- public function search(string $search, string $objectType, string $objectId, string $verb): array {
+ public function search(string $search, string $objectType, string $objectId, string $verb, int $offset, int $limit = 50): array {
$query = $this->dbConn->getQueryBuilder();
$query->select('*')
@@ -511,7 +513,8 @@ class Manager implements ICommentsManager {
'%' . $this->dbConn->escapeLikeParameter($search). '%'
)))
->orderBy('creation_timestamp', 'DESC')
- ->addOrderBy('id', 'DESC');
+ ->addOrderBy('id', 'DESC')
+ ->setMaxResults($limit);
if ($objectType !== '') {
$query->andWhere($query->expr()->eq('object_type', $query->createNamedParameter($objectType)));
@@ -522,6 +525,9 @@ class Manager implements ICommentsManager {
if ($verb !== '') {
$query->andWhere($query->expr()->eq('verb', $query->createNamedParameter($verb)));
}
+ if ($offset !== 0) {
+ $query->setFirstResult($offset);
+ }
$comments = [];
$result = $query->execute();