Less magic

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-10-21 09:47:40 +02:00
parent d462439a63
commit 6400221fba
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
1 changed files with 12 additions and 4 deletions

View File

@ -435,7 +435,11 @@ class Manager implements ICommentsManager {
if ($lastKnownComment instanceof IComment) {
$lastKnownCommentDateTime = $lastKnownComment->getCreationDateTime();
if ($sortDirection === 'desc') {
$idComparison = $includeLastKnown ? 'lte' : 'lt';
if ($includeLastKnown) {
$idComparison = $query->expr()->lte('id', $query->createNamedParameter($lastKnownCommentId));
} else {
$idComparison = $query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId));
}
$query->andWhere(
$query->expr()->orX(
$query->expr()->lt(
@ -449,12 +453,16 @@ class Manager implements ICommentsManager {
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
$query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
$idComparison
)
)
);
} else {
$idComparison = $includeLastKnown ? 'gte' : 'gt';
if ($includeLastKnown) {
$idComparison = $query->expr()->gte('id', $query->createNamedParameter($lastKnownCommentId));
} else {
$idComparison = $query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId));
}
$query->andWhere(
$query->expr()->orX(
$query->expr()->gt(
@ -468,7 +476,7 @@ class Manager implements ICommentsManager {
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
$query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
$idComparison
)
)
);