поправил треды с pregame и pregame-full-stats, когда матч ОНЛАЙН они перестают обновляться. и поправил функцию team, что если данных по сезону и карьере нет, то мы спокойно отрабатывает с данными по текущей игре
This commit is contained in:
15
get_data.py
15
get_data.py
@@ -193,6 +193,7 @@ def start_live_threads(season, game_id):
|
|||||||
),
|
),
|
||||||
600,
|
600,
|
||||||
stop_event_live,
|
stop_event_live,
|
||||||
|
True,
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
),
|
),
|
||||||
@@ -205,6 +206,7 @@ def start_live_threads(season, game_id):
|
|||||||
),
|
),
|
||||||
600,
|
600,
|
||||||
stop_event_live,
|
stop_event_live,
|
||||||
|
True,
|
||||||
),
|
),
|
||||||
daemon=True,
|
daemon=True,
|
||||||
),
|
),
|
||||||
@@ -1436,15 +1438,18 @@ async def team(who: str):
|
|||||||
|
|
||||||
full_stat = get_latest_game_safe("pregame-full-stats")
|
full_stat = get_latest_game_safe("pregame-full-stats")
|
||||||
if not full_stat:
|
if not full_stat:
|
||||||
raise HTTPException(status_code=503, detail="pregame-full-stats data not ready")
|
# ⚠️ full_stat_data отсутствует — работаем только с game_data
|
||||||
|
logger.debug(f"[{who}] full_stat_data not found → continuing with game_data only")
|
||||||
|
full_stat_data = {}
|
||||||
|
else:
|
||||||
|
full_stat_data = full_stat["data"] if "data" in full_stat else full_stat
|
||||||
|
|
||||||
# нормализуем доступ к данным
|
# нормализуем доступ к данным
|
||||||
game_data = game["data"] if "data" in game else game
|
game_data = game["data"] if "data" in game else game
|
||||||
full_stat_data = full_stat["data"] if "data" in full_stat else full_stat
|
|
||||||
result = game_data[
|
result = game_data[
|
||||||
"result"
|
"result"
|
||||||
] # здесь уже безопасно, мы проверили в get_latest_game_safe
|
] # здесь уже безопасно, мы проверили в get_latest_game_safe
|
||||||
result_full = full_stat_data["result"]
|
result_full = full_stat_data.get("result", {}) if full_stat_data else {}
|
||||||
|
|
||||||
# в result ожидаем "teams"
|
# в result ожидаем "teams"
|
||||||
teams = result.get("teams")
|
teams = result.get("teams")
|
||||||
@@ -1455,10 +1460,10 @@ async def team(who: str):
|
|||||||
# выбираем команду
|
# выбираем команду
|
||||||
if who == "team1":
|
if who == "team1":
|
||||||
payload = next((t for t in teams if t.get("teamNumber") == 1), None)
|
payload = next((t for t in teams if t.get("teamNumber") == 1), None)
|
||||||
payload_full = result_full.get("team1PlayersStats")
|
payload_full = result_full.get("team1PlayersStats") if result_full else []
|
||||||
else:
|
else:
|
||||||
payload = next((t for t in teams if t.get("teamNumber") == 2), None)
|
payload = next((t for t in teams if t.get("teamNumber") == 2), None)
|
||||||
payload_full = result_full.get("team2PlayersStats")
|
payload_full = result_full.get("team2PlayersStats") if result_full else []
|
||||||
|
|
||||||
if payload is None:
|
if payload is None:
|
||||||
raise HTTPException(status_code=404, detail=f"{who} not found in game data")
|
raise HTTPException(status_code=404, detail=f"{who} not found in game data")
|
||||||
|
|||||||
Reference in New Issue
Block a user