trying to get NFL upcoming to work

This commit is contained in:
Chuck
2025-07-21 21:49:49 -05:00
parent ba232c58b7
commit 580a71e6c5
3 changed files with 32 additions and 5 deletions

View File

@@ -969,6 +969,10 @@ class MiLBRecentManager(BaseMiLBManager):
logger.info(f"[MiLB] Processing {len(games)} games for recent games...")
# Log all games found for debugging
all_games_log = []
favorite_games_log = []
for game_id, game in games.items():
# Convert game time to UTC datetime
game_time_str = game['start_time'].replace('Z', '+00:00')
@@ -980,7 +984,12 @@ class MiLBRecentManager(BaseMiLBManager):
is_favorite_game = (game['home_team'] in self.favorite_teams or
game['away_team'] in self.favorite_teams)
# Log all games for debugging
game_info = f"{game['away_team']} @ {game['home_team']} (Status: {game['status']}, State: {game['status_state']})"
all_games_log.append(game_info)
if is_favorite_game:
favorite_games_log.append(game_info)
logger.info(f"[MiLB] Checking favorite team game: {game['away_team']} @ {game['home_team']}")
logger.info(f"[MiLB] Game time (UTC): {game_time}")
logger.info(f"[MiLB] Game status: {game['status']}, State: {game['status_state']}")
@@ -996,6 +1005,10 @@ class MiLBRecentManager(BaseMiLBManager):
new_recent_games.append(game)
logger.info(f"[MiLB] Added favorite team game to recent list: {game['away_team']} @ {game['home_team']}")
# Log summary of all games found
logger.info(f"[MiLB] All games found ({len(all_games_log)}): {all_games_log}")
logger.info(f"[MiLB] Favorite team games found ({len(favorite_games_log)}): {favorite_games_log}")
# Sort by game time (most recent first) and limit to recent_games_to_show
new_recent_games.sort(key=lambda x: x['start_time'], reverse=True)
new_recent_games = new_recent_games[:self.recent_games_to_show]

View File

@@ -1101,6 +1101,10 @@ class MLBRecentManager(BaseMLBManager):
self.logger.info(f"[MLB] Processing {len(games)} games for recent games...")
# Log all games found for debugging
all_games_log = []
favorite_games_log = []
for game_id, game in games.items():
self.logger.debug(f"[MLB] Processing game {game_id} for recent games...")
# Convert game time to UTC datetime
@@ -1113,14 +1117,20 @@ class MLBRecentManager(BaseMLBManager):
is_favorite_game = (game['home_team'] in self.favorite_teams or
game['away_team'] in self.favorite_teams)
# Log all games for debugging
game_info = f"{game['away_team']} @ {game['home_team']} (Status: {game['status']}, State: {game['status_state']})"
all_games_log.append(game_info)
if is_favorite_game:
favorite_games_log.append(game_info)
self.logger.info(f"[MLB] Favorite team game found: {game['away_team']} @ {game['home_team']}")
self.logger.info(f"[MLB] Game time (UTC): {game_time}")
self.logger.info(f"[MLB] Game status: {game['status']}, State: {game['status_state']}")
if not is_favorite_game:
self.logger.debug(f"[MLB] Skipping game {game_id} - not a favorite team.")
continue
self.logger.info(f"[MLB] Favorite team game found: {game['away_team']} @ {game['home_team']}")
self.logger.info(f"[MLB] Game time (UTC): {game_time}")
self.logger.info(f"[MLB] Game status: {game['status']}, State: {game['status_state']}")
# Use status_state to determine if game is final
is_final = game['status_state'] in ['post', 'final', 'completed']
@@ -1135,6 +1145,10 @@ class MLBRecentManager(BaseMLBManager):
else:
self.logger.info(f"[MLB] Skipping game {game_id} - not final.")
# Log summary of all games found
self.logger.info(f"[MLB] All games found ({len(all_games_log)}): {all_games_log}")
self.logger.info(f"[MLB] Favorite team games found ({len(favorite_games_log)}): {favorite_games_log}")
# Sort by game time (most recent first) and limit to recent_games_to_show
new_recent_games.sort(key=lambda x: x['start_time'], reverse=True)
new_recent_games = new_recent_games[:self.recent_games_to_show]

View File

@@ -154,7 +154,7 @@ class BaseNFLManager: # Renamed class
response.raise_for_status()
data = response.json()
events = data.get('events', [])
BaseNFLManager.cache_manager.set(cache_key, events, expiration_seconds=86400) # Cache for 24 hours
BaseNFLManager.cache_manager.set(cache_key, events) # Cache for 24 hours
self.logger.info(f"[NFL] Successfully fetched and cached {len(events)} events for the {current_year} season.")
except requests.exceptions.RequestException as e:
self.logger.error(f"[NFL] API error fetching full schedule: {e}")