Skip to content

Commit d928fcd

Browse files
committed
switch milb upcoming flag from final to preview
1 parent bb52bfd commit d928fcd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/milb_manager.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ def _fetch_milb_api_data(self) -> Dict[str, Any]:
343343
sport_ids = self.milb_config.get('sport_ids', [10, 11, 12, 13, 14, 15]) # Mexican, AAA, AA, A+, A, Rookie
344344

345345
now = datetime.now(timezone.utc)
346-
dates = [(now + timedelta(days=d)).strftime("%Y-%m-%d") for d in range(-1, 2)] # Yesterday, today, tomorrow
346+
# Extend date range to look further into the future for upcoming games
347+
# Look back 1 day and forward 7 days to catch more upcoming games
348+
dates = [(now + timedelta(days=d)).strftime("%Y-%m-%d") for d in range(-1, 8)]
347349

348350
all_games = {}
349351

@@ -398,7 +400,7 @@ def _fetch_milb_api_data(self) -> Dict[str, Any]:
398400

399401
if not self.favorite_teams or is_favorite_game:
400402
status_obj = event['status']
401-
status_state = status_obj.get('abstractGameState', 'Final')
403+
status_state = status_obj.get('abstractGameState', 'Preview') # Changed default to 'Preview'
402404

403405
# Map status to a consistent format
404406
status_map = {
@@ -1152,13 +1154,22 @@ def update(self):
11521154
if game_time.tzinfo is None:
11531155
game_time = game_time.replace(tzinfo=timezone.utc)
11541156

1157+
current_time = datetime.now(timezone.utc)
11551158
is_upcoming = (
11561159
game['status_state'] not in ['post', 'final', 'completed'] and
1157-
game_time > datetime.now(timezone.utc)
1160+
game_time > current_time
11581161
)
11591162

1163+
# Add debug logging for upcoming games logic
1164+
self.logger.debug(f"[MiLB] Game {game['away_team']} @ {game['home_team']}:")
1165+
self.logger.debug(f"[MiLB] Game time: {game_time}")
1166+
self.logger.debug(f"[MiLB] Current time: {current_time}")
1167+
self.logger.debug(f"[MiLB] Status state: {game['status_state']}")
1168+
self.logger.debug(f"[MiLB] Is upcoming: {is_upcoming}")
1169+
11601170
if is_upcoming:
11611171
new_upcoming_games.append(game)
1172+
self.logger.info(f"[MiLB] Added upcoming game: {game['away_team']} @ {game['home_team']} at {game_time}")
11621173

11631174
# Sort by game time (soonest first) and limit to upcoming_games_to_show
11641175
new_upcoming_games.sort(key=lambda x: x['start_time'])

0 commit comments

Comments
 (0)