defaults for the search implemented

This commit is contained in:
Priec
2026-06-22 21:18:13 +02:00
parent f512fbbb94
commit 1e66bfd657
2 changed files with 4 additions and 4 deletions

View File

@@ -164,13 +164,13 @@ async fn run_search(
let filter = view::category_filter_ids(&all_categories, &selected_category);
items.retain(|i| view::category_filter_keep(&filter, i.product.category_id));
// 6. Sort. Relevance is the default; with no text query it keeps the base
// order (newest-first), and with a query it keeps the ranked search order.
// 6. Sort. Newest-first is the default; relevance (the ranked search order)
// is available explicitly via the sort control.
let sort = params
.sort
.clone()
.filter(|s| !s.is_empty())
.unwrap_or_else(|| "relevance".to_string());
.unwrap_or_else(|| "newest".to_string());
match sort.as_str() {
"price_asc" => items.sort_by(|a, b| a.priced.price_cents.cmp(&b.priced.price_cents)),
"price_desc" => items.sort_by(|a, b| b.priced.price_cents.cmp(&a.priced.price_cents)),