feat: explain recommendations
CI / test (push) Successful in 19s

This commit is contained in:
strsv committed 2026-11-06 09:35:55 +03:00
1 parent deb0fa9383
commit ce0794a78e
12 files changed
+46 -9

No files matched your search

+16 -2
View File
@@ -198,8 +198,21 @@ def recommend(con, mood, allowed_statuses=None, unplayed_only=False,
score += 2 if r["installed"] else 0
score += 3 if r["status"] == "backlog" else 0
score += 4 if r["status"] == "playing" else 0
if liked_tags:
score += min(8.0, 1.5 * len(liked_tags & tags))
like_bonus = min(8.0, 1.5 * len(liked_tags & tags)) if liked_tags else 0.0
score += like_bonus
reasons = []
if like_bonus:
reasons.append("Похоже на игры, отмеченные «в точку»")
if matched:
reasons.append("Теги: " + ", ".join(matched[:3]))
if hit_genres:
reasons.append("Жанры: " + ", ".join(sorted(hit_genres)))
if r["minutes"] == 0:
reasons.append("Ещё не запускали")
elif r["installed"]:
reasons.append("Установлена")
if r["review_pct"] is not None and r["review_pct"] >= 85:
reasons.append(f"Отзывы {r['review_pct']}%")
results.append({
"appid": r["appid"],
"name": r["name"],
@@ -216,6 +229,7 @@ def recommend(con, mood, allowed_statuses=None, unplayed_only=False,
"notes": r["notes"],
"release": r["release_date"],
"feedback": feedback.get(r["appid"]),
"reasons": reasons[:3],
})
results.sort(key=lambda g: -g["score"])
return mood, results[:limit]