tri par défaut : arrivages récents (first_seen DESC) au lieu du prix croissant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 changed files +5 −5
modified
autoka/web.py
+2 −2
@@ -113,7 +113,7 @@ def list_vehicles( | ||
| 113 | 113 | price_max: float | None = None, |
| 114 | 114 | km_max: float | None = None, |
| 115 | 115 | q: str | None = None, |
| 116 | − sort: str = "price_asc", | |
| 116 | + sort: str = "recent", | |
| 117 | 117 | active: int = 1, |
| 118 | 118 | dedup: int = 1, |
| 119 | 119 | limit: int = Query(60, le=500), |
@@ -135,7 +135,7 @@ def list_vehicles( | ||
| 135 | 135 | price_min=price_min, price_max=price_max, |
| 136 | 136 | km_max=km_max, q=q) |
| 137 | 137 | total = con.execute(f"SELECT COUNT(*) c FROM ({sql})", args).fetchone()["c"] |
| 138 | − sql += f" ORDER BY {_SORTS.get(sort, _SORTS['price_asc'])} LIMIT ? OFFSET ?" | |
| 138 | + sql += f" ORDER BY {_SORTS.get(sort, _SORTS['recent'])} LIMIT ? OFFSET ?" | |
| 139 | 139 | args += [limit, offset] |
| 140 | 140 | rows = [_row_to_dict(r) for r in con.execute(sql, args).fetchall()] |
| 141 | 141 | con.close() |
modified
frontend/src/pages/Home.tsx
+3 −3
@@ -13,11 +13,11 @@ import VehicleCard from "../components/VehicleCard"; | ||
| 13 | 13 | const PAGE_SIZE = 24; |
| 14 | 14 | |
| 15 | 15 | const SORTS = [ |
| 16 | + { v: "recent", label: "Arrivages récents" }, | |
| 16 | 17 | { v: "price_asc", label: "Prix croissant" }, |
| 17 | 18 | { v: "price_desc", label: "Prix décroissant" }, |
| 18 | 19 | { v: "km_asc", label: "Kilométrage croissant" }, |
| 19 | 20 | { v: "year_desc", label: "Année récente" }, |
| 20 | − { v: "recent", label: "Arrivages récents" }, | |
| 21 | 21 | ]; |
| 22 | 22 | |
| 23 | 23 | const PRICE_STEPS = [5000, 10000, 15000, 20000, 25000, 30000, 40000, 50000, 75000, 100000]; |
@@ -66,7 +66,7 @@ export default function Home({ kind = "auto", fixed, seoH1, seoIntro }: HomeProp | ||
| 66 | 66 | fuel: g("fuel"), transmission: g("trans"), region: g("region"), |
| 67 | 67 | source: g("source"), year_min: gn("ymin"), year_max: gn("ymax"), |
| 68 | 68 | price_max: gn("pmax"), km_max: gn("kmax"), q: g("q"), |
| 69 | − sort: g("sort") || "price_asc", | |
| 69 | + sort: g("sort") || "recent", | |
| 70 | 70 | limit: PAGE_SIZE, |
| 71 | 71 | offset: (Math.max(1, gn("page") || 1) - 1) * PAGE_SIZE, |
| 72 | 72 | ...fixed, |
@@ -281,7 +281,7 @@ export default function Home({ kind = "auto", fixed, seoH1, seoIntro }: HomeProp | ||
| 281 | 281 | </h2> |
| 282 | 282 | <div className="sort-box"> |
| 283 | 283 | <label htmlFor="f-sort">Trier</label> |
| 284 | − <select id="f-sort" value={params.get("sort") || "price_asc"} onChange={(e) => setFilter("sort", e.target.value)}> | |
| 284 | + <select id="f-sort" value={params.get("sort") || "recent"} onChange={(e) => setFilter("sort", e.target.value)}> | |
| 285 | 285 | {SORTS.map((s) => ( |
| 286 | 286 | <option key={s.v} value={s.v}>{s.label}</option> |
| 287 | 287 | ))} |
| 288 | 288 | |