3.0.3: Cant fix team avg. removed.

This commit is contained in:
2026-01-29 23:44:02 +08:00
parent 3bb3d61c2e
commit ba5bf14ee2
10 changed files with 220 additions and 84 deletions

View File

@@ -166,33 +166,13 @@ class FeatureService:
lineups = WebService.get_lineups()
roster_ids: list[str] = []
# Try to find a lineup containing this player
if lineups:
for lineup in lineups:
try:
p_ids = [str(i) for i in json.loads(lineup.get("player_ids_json") or "[]")]
if str(target_steam_id) in p_ids:
roster_ids = p_ids
break
except Exception:
continue
# If not found in any lineup, use the most recent lineup as a fallback context
if not roster_ids and lineups:
try:
roster_ids = [str(i) for i in json.loads(lineups[0].get("player_ids_json") or "[]")]
except Exception:
roster_ids = []
# If still no roster (e.g. no lineups at all), fallback to a "Global Context" (Top 50 active players)
# This ensures we always have a distribution to compare against
if not roster_ids:
rows = query_db("l3", "SELECT steam_id_64 FROM dm_player_features ORDER BY last_match_date DESC LIMIT 50")
roster_ids = [str(r['steam_id_64']) for r in rows] if rows else []
# Ensure target player is in the list
if str(target_steam_id) not in roster_ids:
roster_ids.append(str(target_steam_id))
try:
p_ids = [str(i) for i in json.loads(lineups[0].get("player_ids_json") or "[]")]
if str(target_steam_id) in p_ids:
roster_ids = p_ids
except Exception:
roster_ids = []
if not roster_ids:
return None