Fix handling of incomplete matches from past days on startup

- Add _cleanup_old_incomplete_matches() to mark 2+ day old matches as failed
- Add _get_yesterday_incomplete_matches() to detect yesterday's incomplete matches
- Add _get_or_create_today_fixture() to ensure new matches go to today's fixture
- Modify initialize() to process past incomplete matches before starting
- Modify _handle_start_game() to use pre-computed yesterday_fixture_id
- Add yesterday_fixture_id attribute to track yesterday's fixture for completion

This ensures:
- Matches from 2+ days ago are marked as failed with bet cancellation
- Yesterday's incomplete matches are played to completion first
- New matches are created in today's fixture, not yesterday's
parent 15d06c2c
...@@ -754,6 +754,14 @@ class GamesThread(ThreadedComponent): ...@@ -754,6 +754,14 @@ class GamesThread(ThreadedComponent):
fixture_id = message.data.get("fixture_id") fixture_id = message.data.get("fixture_id")
# PRIORITY CHECK: If we have yesterday's incomplete matches from initialization, use those first
if self.yesterday_fixture_id and not fixture_id:
logger.info(f"🎯 Found yesterday's incomplete fixture from initialization: {self.yesterday_fixture_id}")
# Use the yesterday fixture ID that was detected during initialization
fixture_id = self.yesterday_fixture_id
# The pending_today_fixture_id should already be set from initialization
logger.info(f"🎯 Will use pre-created today fixture: {self.pending_today_fixture_id}")
if fixture_id: if fixture_id:
# Case 1: fixture_id is provided # Case 1: fixture_id is provided
logger.info(f"Fixture ID {fixture_id} provided - checking fixture availability") logger.info(f"Fixture ID {fixture_id} provided - checking fixture availability")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment