Skip to content

Commit ece7bf5

Browse files
fix(preview): order previews by ID during pagination
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent fb05f77 commit ece7bf5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/private/Preview/Db/PreviewMapper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,17 @@ public function getPreviews(string $lastId, int $limit = self::MAX_CHUNK_SIZE, ?
213213
$qb = $this->db->getQueryBuilder();
214214
$this->joinLocation($qb)
215215
->where($qb->expr()->gt('p.id', $qb->createNamedParameter($lastId)))
216+
->orderBy('p.id', 'ASC')
216217
->setMaxResults($limit);
217218

218219
if ($maxAgeDays !== null) {
219-
$qb->andWhere($qb->expr()->lt('mtime', $qb->createNamedParameter((new DateTimeImmutable())->sub(new DateInterval('P' . $maxAgeDays . 'D'))->getTimestamp(), IQueryBuilder::PARAM_INT)));
220+
$qb->andWhere($qb->expr()->lt(
221+
'p.mtime',
222+
$qb->createNamedParameter(
223+
(new DateTimeImmutable())->sub(new DateInterval('P' . $maxAgeDays . 'D'))->getTimestamp(),
224+
IQueryBuilder::PARAM_INT,
225+
),
226+
));
220227
}
221228

222229
return $this->yieldEntities($qb);

0 commit comments

Comments
 (0)