BUILD151 — schedule_live + toggle ОНЛАЙН

This commit is contained in:
2026-09-18 20:07:47 +03:00
parent 1c00642791
commit eed07cd47c
4 changed files with 557 additions and 100 deletions

35
app.py
View File

@@ -30,7 +30,7 @@ from ui_builder import install_ui_builder
from khl_site.khl_data_center import APP as khl_site_app
BASE_DIR = Path(__file__).resolve().parent
BUILD_VERSION = "2026.09.18.8"
BUILD_VERSION = "2026.09.18.9"
# compatibility: BUILD_VERSION = "2026.08.26.1"
# compatibility: BUILD_VERSION = "2026.08.25.1"
# compatibility: BUILD_VERSION = "2026.08.24.15"
@@ -82,6 +82,8 @@ hockey_agent_hub = VmixAgentHub(hockey_database, settings=hockey_settings)
@app.on_event("startup")
async def hockey_mapping_auto_refresh_startup() -> None:
# BUILD151: isolated per-second schedule polling writes only to schedule_live.
hockey_service.ensure_schedule_live_table()
hockey_agent_hub.start_auto_refresh()
# BUILD143: schedules, standings and authoritative per-game scores refresh
# on the server even when no browser/operator is open.
@@ -389,19 +391,22 @@ async def refresh_tournament_schedule_online(
external_id: str,
on_date: date = Query(...),
language: str = Query("ru", pattern="^(ru|en)$"),
mode: str = Query("seed", pattern="^(seed|live|discover)$"),
) -> dict[str, Any]:
"""Refresh score/status for every game on one schedule date from match JSON.
"""Refresh the isolated schedule_live snapshot from per-game JSON.
RU explicitly reads ``json/{game_id}.json`` and EN explicitly reads
``json_en/{game_id}.json``. No schedule XML is fetched by this button.
``seed`` checks every match once, ``live`` checks only rows currently live,
and ``discover`` checks non-finished rows so newly-started games are found.
The base hockey_games table is never modified by this endpoint.
"""
if hockey_service.tournament(external_id, language=language) is None:
raise HTTPException(status_code=404, detail="Турнир не найден")
try:
return await hockey_service.refresh_schedule_from_match_json(
return await hockey_service.refresh_schedule_live_from_match_json(
tournament_external_id=external_id,
on_date=on_date,
language=language,
mode=mode,
)
except ValueError as error:
raise HTTPException(status_code=400, detail=str(error)) from error
@@ -409,6 +414,26 @@ async def refresh_tournament_schedule_online(
raise HTTPException(status_code=502, detail=str(error)) from error
@app.get(
"/api/hockey/tournaments/{external_id}/games/live-schedule",
dependencies=[Depends(hockey_auth.require_user)],
tags=["Hockey"],
)
async def tournament_live_schedule(
external_id: str,
on_date: date = Query(...),
language: str = Query("ru", pattern="^(ru|en)$"),
) -> dict[str, Any]:
"""Read score/status from schedule_live without modifying hockey_games."""
if hockey_service.tournament(external_id, language=language) is None:
raise HTTPException(status_code=404, detail="Турнир не найден")
return hockey_service.schedule_live(
tournament_external_id=external_id,
on_date=on_date,
language=language,
)
@app.post(
"/api/hockey/tournaments/{external_id}/standings/force-sync",
dependencies=[Depends(hockey_auth.require_user)],