Make search returns 0 hits when pages is set to 0

This commit is contained in:
ManyTheFish 2022-07-21 18:03:39 +02:00
parent dfa70e47f7
commit e35ea2ad55

View File

@ -152,13 +152,16 @@ impl Index {
search.exhaustive_number_hits(is_finite_pagination); search.exhaustive_number_hits(is_finite_pagination);
let (offset, limit) = if is_finite_pagination { let (offset, limit) = if is_finite_pagination {
let offset = min( match query.page.checked_sub(1) {
query.hits_per_page * (query.page.saturating_sub(1)), Some(page) => {
max_total_hits, let offset = min(query.hits_per_page * page, max_total_hits);
); let limit = min(query.hits_per_page, max_total_hits.saturating_sub(offset));
let limit = min(query.hits_per_page, max_total_hits.saturating_sub(offset));
(offset, limit) (offset, limit)
}
// page 0 returns 0 hits
None => (0, 0),
}
} else { } else {
let offset = min(query.offset.unwrap_or(0), max_total_hits); let offset = min(query.offset.unwrap_or(0), max_total_hits);
let limit = min( let limit = min(