postgres: Enable 'previous page' when less than full limit fit on previous page

This commit is contained in:
asonix 2023-09-03 21:58:31 -05:00
parent e961bdc331
commit 00aa00c55c

View file

@ -354,11 +354,11 @@ impl HashRepo for PostgresRepo {
.or_filter(created_at.eq(timestamp).and(hash.gt(&bound_hash)))
.order(created_at)
.then_order_by(hash)
.offset(limit.saturating_sub(1) as i64)
.first::<Hash>(&mut conn)
.limit(limit as i64)
.get_results::<Hash>(&mut conn)
.await
.optional()
.map_err(PostgresError::Diesel)?;
.map_err(PostgresError::Diesel)?
.pop();
(page, prev)
} else {