Fix fixtures API: convert timezone-aware datetime to naive for database comparison

parent dd10456c
...@@ -10745,11 +10745,20 @@ def get_overlay_fixtures(): ...@@ -10745,11 +10745,20 @@ def get_overlay_fixtures():
logger.info(f"[FIXTURES API] today_start_utc: {today_start_utc}, today_end_utc: {today_end_utc}") logger.info(f"[FIXTURES API] today_start_utc: {today_start_utc}, today_end_utc: {today_end_utc}")
logger.info(f"[FIXTURES API] yesterday_start_utc: {yesterday_start_utc}, yesterday_end_utc: {yesterday_end_utc}") logger.info(f"[FIXTURES API] yesterday_start_utc: {yesterday_start_utc}, yesterday_end_utc: {yesterday_end_utc}")
# Convert timezone-aware datetime to timezone-naive for database comparison
# Database stores start_time without timezone info
today_start_naive = today_start_utc.replace(tzinfo=None) if today_start_utc.tzinfo else today_start_utc
today_end_naive = today_end_utc.replace(tzinfo=None) if today_end_utc.tzinfo else today_end_utc
yesterday_start_naive = yesterday_start_utc.replace(tzinfo=None) if yesterday_start_utc.tzinfo else yesterday_start_utc
yesterday_end_naive = yesterday_end_utc.replace(tzinfo=None) if yesterday_end_utc.tzinfo else yesterday_end_utc
logger.info(f"[FIXTURES API] today_start_naive: {today_start_naive}, today_end_naive: {today_end_naive}")
# Get active matches for today (non-terminal states) - same as Qt player # Get active matches for today (non-terminal states) - same as Qt player
today_matches = session.query(MatchModel).filter( today_matches = session.query(MatchModel).filter(
MatchModel.start_time.isnot(None), MatchModel.start_time.isnot(None),
MatchModel.start_time >= today_start_utc, MatchModel.start_time >= today_start_naive,
MatchModel.start_time < today_end_utc, MatchModel.start_time < today_end_naive,
MatchModel.status.notin_(['done', 'end', 'cancelled', 'failed', 'paused']), MatchModel.status.notin_(['done', 'end', 'cancelled', 'failed', 'paused']),
MatchModel.active_status == True MatchModel.active_status == True
).order_by(MatchModel.start_time.asc()).all() ).order_by(MatchModel.start_time.asc()).all()
...@@ -10759,8 +10768,8 @@ def get_overlay_fixtures(): ...@@ -10759,8 +10768,8 @@ def get_overlay_fixtures():
# Check if there are any incomplete matches from yesterday - same as Qt player # Check if there are any incomplete matches from yesterday - same as Qt player
yesterday_incomplete_matches = session.query(MatchModel).filter( yesterday_incomplete_matches = session.query(MatchModel).filter(
MatchModel.start_time.isnot(None), MatchModel.start_time.isnot(None),
MatchModel.start_time >= yesterday_start_utc, MatchModel.start_time >= yesterday_start_naive,
MatchModel.start_time < yesterday_end_utc, MatchModel.start_time < yesterday_end_naive,
MatchModel.status.notin_(['done', 'end', 'cancelled', 'failed', 'paused']), MatchModel.status.notin_(['done', 'end', 'cancelled', 'failed', 'paused']),
MatchModel.active_status == True MatchModel.active_status == True
).order_by(MatchModel.start_time.asc()).all() ).order_by(MatchModel.start_time.asc()).all()
......
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