feat: estimate game duration from genres and tags
CI / test (push) Successful in 15s

This commit is contained in:
strsv committed 2026-11-06 17:21:21 +03:00
1 parent b65c8c39fe
commit b2ab347129
18 files changed
+166 -25

No files matched your search

+14 -1
View File
@@ -439,6 +439,7 @@ def serialize(r, tags, genres, details):
"review": r["review_pct"],
"metacritic": r["metacritic"],
"hours": round((r["minutes"] or 0) / 60, 1),
"duration": r["estimated_hours"],
"installed": bool(r["installed"]),
"status": r["status"],
"rating": r["rating"],
@@ -841,12 +842,22 @@ class Handler(BaseHTTPRequestHandler):
where.append("g.review_pct <= ?")
params.append(max_review)
duration = q("duration")
if duration == "short":
where.append("COALESCE(g.estimated_hours, 999) <= 8")
elif duration == "medium":
where.append("COALESCE(g.estimated_hours, 999) > 8 "
"AND COALESCE(g.estimated_hours, 999) <= 25")
elif duration == "long":
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")
@@ -862,7 +873,8 @@ class Handler(BaseHTTPRequestHandler):
try:
total = con.execute(f"SELECT COUNT(*) c {base}", params).fetchone()["c"]
rows = con.execute(
f"""SELECT g.appid, g.name, g.release_date, g.metacritic, g.review_pct,
f""" SELECT g.appid, g.name, g.release_date, g.metacritic, g.review_pct,
g.estimated_hours,
COALESCE(p.minutes,0) minutes, COALESCE(i.installed,0) installed,
COALESCE(pe.status,'backlog') status, pe.rating,
COALESCE(pe.favorite,0) favorite, pe.notes
@@ -885,6 +897,7 @@ class Handler(BaseHTTPRequestHandler):
try:
r = con.execute("""
SELECT g.appid, g.name, g.type, g.release_date, g.metacritic, g.review_pct,
g.estimated_hours,
COALESCE(p.minutes,0) minutes, p.last_played,
COALESCE(i.installed,0) installed, i.size_bytes,
COALESCE(pe.status,'backlog') status, pe.rating,