mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(search): use clamp for page bounds
Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
parent
a3f407ce96
commit
0bd34eac8f
@@ -163,7 +163,7 @@ pub async fn search(pool: &PgPool, query: &SearchQuery) -> Result<SearchResult,
|
||||
let Some(search_text) = normalized_search_text(&query.q) else {
|
||||
return Ok(SearchResult {
|
||||
hits: Vec::new(),
|
||||
page: query.page.max(1).min(PAGE_MAX),
|
||||
page: query.page.clamp(1, PAGE_MAX),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -173,7 +173,7 @@ pub async fn search(pool: &PgPool, query: &SearchQuery) -> Result<SearchResult,
|
||||
} else {
|
||||
per_page
|
||||
};
|
||||
let page = query.page.max(1).min(PAGE_MAX);
|
||||
let page = query.page.clamp(1, PAGE_MAX);
|
||||
let offset = ((page - 1) as i64) * (per_page_actual as i64);
|
||||
|
||||
let mut qb: QueryBuilder<sqlx::Postgres> = QueryBuilder::new(
|
||||
|
||||
Reference in New Issue
Block a user