mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-13 22:13:00 +00:00
Add detailed logging to MLBRecentManager to diagnose missing games
This commit is contained in:
@@ -457,31 +457,46 @@ class MLBRecentManager(BaseMLBManager):
|
|||||||
try:
|
try:
|
||||||
# Fetch data from MLB API
|
# Fetch data from MLB API
|
||||||
games = self._fetch_mlb_api_data()
|
games = self._fetch_mlb_api_data()
|
||||||
if games:
|
if not games:
|
||||||
|
logger.warning("[MLB] No games returned from API")
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f"[MLB] Found {len(games)} total games in API response")
|
||||||
|
|
||||||
# Process games
|
# Process games
|
||||||
new_recent_games = []
|
new_recent_games = []
|
||||||
now = datetime.now(timezone.utc) # Make timezone-aware
|
now = datetime.now(timezone.utc) # Make timezone-aware
|
||||||
recent_cutoff = now - timedelta(hours=self.recent_hours)
|
recent_cutoff = now - timedelta(hours=self.recent_hours)
|
||||||
|
|
||||||
logger.info(f"Looking for games between {recent_cutoff} and {now}")
|
logger.info(f"[MLB] Looking for games between {recent_cutoff} and {now}")
|
||||||
|
logger.info(f"[MLB] Recent hours setting: {self.recent_hours}")
|
||||||
|
|
||||||
for game in games.values():
|
for game in games.values():
|
||||||
game_time = datetime.fromisoformat(game['start_time'].replace('Z', '+00:00'))
|
game_time = datetime.fromisoformat(game['start_time'].replace('Z', '+00:00'))
|
||||||
logger.info(f"Checking game: {game['away_team']} @ {game['home_team']} at {game_time}")
|
logger.info(f"[MLB] Checking game: {game['away_team']} @ {game['home_team']} at {game_time}")
|
||||||
logger.info(f"Game status: {game['status']}")
|
logger.info(f"[MLB] Game status: {game['status']}")
|
||||||
|
|
||||||
if game['status'] == 'final' and recent_cutoff <= game_time <= now:
|
is_final = game['status'] == 'final'
|
||||||
|
is_within_time = recent_cutoff <= game_time <= now
|
||||||
|
|
||||||
|
logger.info(f"[MLB] Is final: {is_final}")
|
||||||
|
logger.info(f"[MLB] Is within time window: {is_within_time}")
|
||||||
|
|
||||||
|
if is_final and is_within_time:
|
||||||
new_recent_games.append(game)
|
new_recent_games.append(game)
|
||||||
logger.info(f"Added game to recent list: {game['away_team']} @ {game['home_team']}")
|
logger.info(f"[MLB] Added game to recent list: {game['away_team']} @ {game['home_team']}")
|
||||||
|
|
||||||
|
logger.info(f"[MLB] Found {len(new_recent_games)} games within time window")
|
||||||
|
|
||||||
# Filter for favorite teams
|
# Filter for favorite teams
|
||||||
new_team_games = [game for game in new_recent_games
|
new_team_games = [game for game in new_recent_games
|
||||||
if game['home_team'] in self.favorite_teams or
|
if game['home_team'] in self.favorite_teams or
|
||||||
game['away_team'] in self.favorite_teams]
|
game['away_team'] in self.favorite_teams]
|
||||||
|
|
||||||
logger.info(f"Found {len(new_team_games)} games for favorite teams: {self.favorite_teams}")
|
logger.info(f"[MLB] Favorite teams: {self.favorite_teams}")
|
||||||
|
logger.info(f"[MLB] Found {len(new_team_games)} games for favorite teams")
|
||||||
for game in new_team_games:
|
for game in new_team_games:
|
||||||
logger.info(f"Favorite team game: {game['away_team']} @ {game['home_team']}")
|
logger.info(f"[MLB] Favorite team game: {game['away_team']} @ {game['home_team']}")
|
||||||
|
|
||||||
if new_team_games:
|
if new_team_games:
|
||||||
logger.info(f"[MLB] Found {len(new_team_games)} recent games for favorite teams")
|
logger.info(f"[MLB] Found {len(new_team_games)} recent games for favorite teams")
|
||||||
|
|||||||
Reference in New Issue
Block a user