From aaa4505380d60c013402d3c4c7b501a097dec4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Tue, 4 Nov 2025 14:23:21 +0300 Subject: [PATCH] =?UTF-8?q?=D1=82=D1=80=D0=B5=D0=B4=20game=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=B6=D0=B4=D1=8B=D0=B5=205=20=D0=BC=D0=B8=D0=BD=D1=83?= =?UTF-8?q?=D1=82=20=D0=B7=D0=B0=201=D1=8710=D0=BC=D0=B8=D0=BD=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BA=D0=B0=20=D0=BC=D0=B0=D1=82=D1=87=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=B5=D1=82=20=D0=9E=D0=9D=D0=9B=D0=90?= =?UTF-8?q?=D0=99=D0=9D.=20=D0=BA=D0=B0=D0=BA=20=D1=82=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20=D0=BE=D0=BD=D0=BB=D0=B0=D0=B9=D0=BD,=20=D1=8D?= =?UTF-8?q?=D1=82=D0=BE=D1=82=20=D1=82=D1=80=D0=B5=D0=B4=20=D0=B3=D0=B0?= =?UTF-8?q?=D1=81=D0=B8=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_data.py | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/get_data.py b/get_data.py index 856afed..489fc8b 100644 --- a/get_data.py +++ b/get_data.py @@ -559,40 +559,36 @@ def results_consumer(): else: if source == "game": - # has_game_already = "teams" in latest_data - has_game_already = "game" in latest_data and isinstance( - latest_data.get("game"), dict - ) + has_game_already = "game" in latest_data and isinstance(latest_data.get("game"), dict) - # есть ли в ответе ПОЛНАЯ структура + # Полная структура? is_full = ( - "data" in payload + isinstance(payload, dict) + and "data" in payload and isinstance(payload["data"], dict) - and "result" in payload["data"] and "teams" in payload["data"]["result"] + and "result" in payload["data"] + and "teams" in payload["data"]["result"] ) - if is_full: - # полный game — всегда кладём - latest_data["game"] = { - "ts": msg["ts"], - "data": payload, - } + # ⚙️ ЛОГИКА: + # 1) Пока матч НЕ online (STATUS != 'live'): обновляем всегда, + # чтобы /status видел "живость" раз в 5 минут независимо от полноты JSON. + if globals().get("STATUS") != "live": + latest_data["game"] = {"ts": msg["ts"], "data": payload} + # можно залогировать для отладки: + logger.debug("results_consumer: pre-live game → updated (full=%s)", is_full) + + # 2) Когда матч УЖЕ online (STATUS == 'live'): + # - поток 'game' в live-режиме погаснет сам (stop_when_live=True), + # но если вдруг что-то долетит, кладём только полный JSON. else: - if ( - globals().get("STATUS") in ("live", "live_soon") - and has_game_already - ): - logger.debug( - "results_consumer: LIVE & partial game → keep previous one" - ) + if is_full: + latest_data["game"] = {"ts": msg["ts"], "data": payload} + logger.debug("results_consumer: LIVE & full game → replaced") else: - if not has_game_already: - # раньше не было вообще — положим хоть что-то - latest_data["game"] = {"ts": msg["ts"], "data": payload} - else: - logger.debug( - "results_consumer: got partial game, keeping previous one" - ) + # Ничего не трогаем, чтобы не затереть полноценные данные пустотой. + logger.debug("results_consumer: LIVE & partial game → keep previous one") + continue # # game неполный # if not has_game_already: # # 👉 раньше game вообще не было — лучше положить хоть что-то