This commit is contained in:
1 parent
21301ca31b
commit
b65c8c39fe
7 files changed
+45
-12
No files matched your search
+18
-5
@@ -206,6 +206,15 @@ def recommend(con, mood, allowed_statuses=None, unplayed_only=False,
|
||||
liked_tags = {r["tag_id"] for r in con.execute(
|
||||
f"SELECT tag_id FROM game_tags WHERE appid IN ({liked_ph})", list(liked_ids))}
|
||||
|
||||
taste_ids = {r["appid"] for r in con.execute(
|
||||
"""SELECT appid FROM personal
|
||||
WHERE COALESCE(favorite, 0) = 1 OR COALESCE(rating, 0) >= 8""")}
|
||||
taste_tags = set()
|
||||
if taste_ids:
|
||||
taste_ph = ",".join("?" * len(taste_ids))
|
||||
taste_tags = {r["tag_id"] for r in con.execute(
|
||||
f"SELECT tag_id FROM game_tags WHERE appid IN ({taste_ph})", list(taste_ids))}
|
||||
|
||||
mood_tags = {k: float(v) for k, v in mood["tags"].items()}
|
||||
denom = 0.0
|
||||
for name, weight in mood_tags.items():
|
||||
@@ -237,19 +246,23 @@ 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
|
||||
like_bonus = min(8.0, 1.5 * len(liked_tags & tags)) if liked_tags else 0.0
|
||||
score += like_bonus
|
||||
like_hit = len(liked_tags & tags)
|
||||
taste_hit = len(taste_tags & tags)
|
||||
score += min(8.0, 1.5 * like_hit)
|
||||
score += min(6.0, 1.0 * taste_hit)
|
||||
reasons = []
|
||||
if like_bonus:
|
||||
if like_hit:
|
||||
reasons.append("Похоже на игры, отмеченные «в точку»")
|
||||
elif taste_hit:
|
||||
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 hit_genres:
|
||||
reasons.append("Жанры: " + ", ".join(sorted(hit_genres)))
|
||||
if r["review_pct"] is not None and r["review_pct"] >= 85:
|
||||
reasons.append(f"Отзывы {r['review_pct']}%")
|
||||
results.append({
|
||||
|
||||
Reference in new issue
Block a user