mirror of
https://github.com/nextcloud/server.git
synced 2026-02-13 15:54:59 -05:00
Include an option to also include the lastKnownCommentId object
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2c21adb5a6
commit
2cc35cc65d
2 changed files with 10 additions and 4 deletions
|
|
@ -395,6 +395,7 @@ class Manager implements ICommentsManager {
|
|||
* @param string $sortDirection direction of the comments (`asc` or `desc`)
|
||||
* @param int $limit optional, number of maximum comments to be returned. if
|
||||
* set to 0, all comments are returned.
|
||||
* @param bool $includeLastKnown
|
||||
* @return IComment[]
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -403,7 +404,8 @@ class Manager implements ICommentsManager {
|
|||
string $objectId,
|
||||
int $lastKnownCommentId,
|
||||
string $sortDirection = 'asc',
|
||||
int $limit = 30
|
||||
int $limit = 30,
|
||||
bool $includeLastKnown = false
|
||||
): array {
|
||||
$comments = [];
|
||||
|
||||
|
|
@ -427,6 +429,7 @@ class Manager implements ICommentsManager {
|
|||
if ($lastKnownComment instanceof IComment) {
|
||||
$lastKnownCommentDateTime = $lastKnownComment->getCreationDateTime();
|
||||
if ($sortDirection === 'desc') {
|
||||
$idComparison = $includeLastKnown ? 'lte' : 'lt';
|
||||
$query->andWhere(
|
||||
$query->expr()->orX(
|
||||
$query->expr()->lt(
|
||||
|
|
@ -440,11 +443,12 @@ class Manager implements ICommentsManager {
|
|||
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
|
||||
IQueryBuilder::PARAM_DATE
|
||||
),
|
||||
$query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId))
|
||||
$query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$idComparison = $includeLastKnown ? 'gte' : 'gt';
|
||||
$query->andWhere(
|
||||
$query->expr()->orX(
|
||||
$query->expr()->gt(
|
||||
|
|
@ -458,7 +462,7 @@ class Manager implements ICommentsManager {
|
|||
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
|
||||
IQueryBuilder::PARAM_DATE
|
||||
),
|
||||
$query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId))
|
||||
$query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ interface ICommentsManager {
|
|||
* @param string $sortDirection direction of the comments (`asc` or `desc`)
|
||||
* @param int $limit optional, number of maximum comments to be returned. if
|
||||
* set to 0, all comments are returned.
|
||||
* @param bool $includeLastKnown
|
||||
* @return IComment[]
|
||||
* @since 14.0.0
|
||||
*/
|
||||
|
|
@ -136,7 +137,8 @@ interface ICommentsManager {
|
|||
string $objectId,
|
||||
int $lastKnownCommentId,
|
||||
string $sortDirection = 'asc',
|
||||
int $limit = 30
|
||||
int $limit = 30,
|
||||
bool $includeLastKnown = false
|
||||
): array;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue