feat: add table sorting, accessibility and session filters
CI / test (push) Successful in 3m18s

This commit is contained in:
strsv committed 2026-11-06 19:20:18 +03:00
1 parent a6db306847
commit 7e4fa74cd6
13 files changed
+363 -63

No files matched your search

+21 -8
View File
@@ -882,14 +882,23 @@ class Handler(BaseHTTPRequestHandler):
where.append("COALESCE(g.estimated_hours, 999) > 25")
sort = q("sort", "name")
order = {
"name": "g.name COLLATE NOCASE ASC",
"hours": "COALESCE(p.minutes,0) DESC, g.name COLLATE NOCASE",
"review": "COALESCE(g.review_pct,0) DESC, g.name COLLATE NOCASE",
"year": "COALESCE(g.release_date,'') DESC, g.name COLLATE NOCASE",
"duration": "COALESCE(g.estimated_hours, 999) ASC, g.name COLLATE NOCASE",
"added": "g.appid DESC",
}.get(sort, "g.name COLLATE NOCASE ASC")
columns = {
"name": "g.name COLLATE NOCASE",
"hours": "COALESCE(p.minutes,0)",
"review": "COALESCE(g.review_pct,0)",
"year": "COALESCE(g.release_date,'')",
"duration": "COALESCE(g.estimated_hours, 999)",
"added": "g.appid",
}
if sort not in columns:
sort = "name"
default_dir = "desc" if sort in ("hours", "review", "year", "added") else "asc"
direction = q("dir", "").lower()
if direction not in ("asc", "desc"):
direction = default_dir
order = f"{columns[sort]} {direction.upper()}"
if sort != "name":
order += ", g.name COLLATE NOCASE ASC"
page = max(1, int(q("page", "1") or 1))
per_page = min(120, max(12, int(q("per_page", "60") or 60)))
@@ -987,6 +996,9 @@ class Handler(BaseHTTPRequestHandler):
if body.get("include_nostalgia"):
allowed.add("nostalgia")
key = reco.mood_key(mood)
session = body.get("session")
if session not in {"short", "evening", "weekend"}:
session = None
mood, results = reco.recommend(
con, mood,
allowed_statuses=allowed,
@@ -995,6 +1007,7 @@ class Handler(BaseHTTPRequestHandler):
allow_unknown=bool(body.get("allow_unknown")),
limit=min(100, int(body.get("limit", 36))),
feedback_key=key,
session=session,
)
ids = [g["appid"] for g in results]
details = details_map(con, ids)