feat: use recency and completion in recommendations
Boost recently played playing/backlog games, penalize completed ones, and explain both in recommendation reasons.
This commit is contained in:
1 parent
4566066f2b
commit
6a1b3aadfc
6 files changed
+67
-3
No files matched your search
@@ -4,6 +4,7 @@ import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from datetime import date
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.join(ROOT, "tools"))
|
||||
@@ -236,6 +237,33 @@ class RecommendTests(RecoFixture):
|
||||
self.con.execute("DELETE FROM reco_feedback WHERE mood_key = ?", (key,))
|
||||
self.con.commit()
|
||||
|
||||
def test_recent_playing_bonus(self):
|
||||
self.con.execute(
|
||||
"INSERT INTO personal (appid, status) VALUES (2, 'playing') "
|
||||
"ON CONFLICT(appid) DO UPDATE SET status = 'playing'")
|
||||
self.con.execute("UPDATE game_playtime SET last_played = ? WHERE appid = 2",
|
||||
(date.today().isoformat(),))
|
||||
self.con.commit()
|
||||
_, results = reco.recommend(self.con, self.mood(), limit=10)
|
||||
beta = next(g for g in results if g["appid"] == 2)
|
||||
self.assertIn("Недавно играли", beta["reasons"])
|
||||
|
||||
def test_recently_started_backlog_bonus(self):
|
||||
self.con.execute("UPDATE game_playtime SET last_played = ? WHERE appid = 3",
|
||||
(date.today().isoformat(),))
|
||||
self.con.commit()
|
||||
_, results = reco.recommend(self.con, self.mood(), limit=10)
|
||||
gamma = next(g for g in results if g["appid"] == 3)
|
||||
self.assertIn("Недавно запускали", gamma["reasons"])
|
||||
|
||||
def test_played_completion_penalty(self):
|
||||
self.con.execute("UPDATE game_playtime SET last_played = ? WHERE appid = 4",
|
||||
(date.today().isoformat(),))
|
||||
self.con.commit()
|
||||
_, results = reco.recommend(self.con, self.mood(), limit=10)
|
||||
delta = next(g for g in results if g["appid"] == 4)
|
||||
self.assertIn("Уже пройдена", delta["reasons"])
|
||||
|
||||
def test_no_eligible_games(self):
|
||||
mood, results = reco.recommend(self.con, self.mood(), allowed_statuses=["tribute"])
|
||||
self.assertEqual(mood["description"], "test")
|
||||
|
||||
Reference in new issue
Block a user