mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 21:33:00 +00:00
Add detailed logging for recent games processing
This commit is contained in:
@@ -478,19 +478,24 @@ class NHLRecentManager(BaseNHLManager):
|
|||||||
# Fetch recent game data from ESPN API
|
# Fetch recent game data from ESPN API
|
||||||
data = self._fetch_data()
|
data = self._fetch_data()
|
||||||
if data and "events" in data:
|
if data and "events" in data:
|
||||||
|
logging.info(f"[NHL] Fetched {len(data['events'])} events from ESPN API")
|
||||||
# Find all completed games involving favorite teams
|
# Find all completed games involving favorite teams
|
||||||
new_recent_games = []
|
new_recent_games = []
|
||||||
for event in data["events"]:
|
for event in data["events"]:
|
||||||
details = self._extract_game_details(event)
|
details = self._extract_game_details(event)
|
||||||
if details and details["is_final"] and details["is_within_window"]:
|
if details:
|
||||||
if not self.favorite_teams or (
|
logging.debug(f"[NHL] Processing game: {details['away_abbr']} vs {details['home_abbr']}")
|
||||||
details["home_abbr"] in self.favorite_teams or
|
logging.debug(f"[NHL] Game status: is_final={details['is_final']}, is_within_window={details['is_within_window']}")
|
||||||
details["away_abbr"] in self.favorite_teams
|
if details["is_final"] and details["is_within_window"]:
|
||||||
):
|
if not self.favorite_teams or (
|
||||||
new_recent_games.append(details)
|
details["home_abbr"] in self.favorite_teams or
|
||||||
logging.info(f"[NHL] Found recent game: {details['away_abbr']} vs {details['home_abbr']}")
|
details["away_abbr"] in self.favorite_teams
|
||||||
|
):
|
||||||
|
new_recent_games.append(details)
|
||||||
|
logging.info(f"[NHL] Found recent game: {details['away_abbr']} vs {details['home_abbr']}")
|
||||||
|
|
||||||
if new_recent_games:
|
if new_recent_games:
|
||||||
|
logging.info(f"[NHL] Found {len(new_recent_games)} recent games for favorite teams")
|
||||||
# Sort games by start time (most recent first)
|
# Sort games by start time (most recent first)
|
||||||
new_recent_games.sort(key=lambda x: x["start_time_utc"], reverse=True)
|
new_recent_games.sort(key=lambda x: x["start_time_utc"], reverse=True)
|
||||||
|
|
||||||
@@ -507,7 +512,9 @@ class NHLRecentManager(BaseNHLManager):
|
|||||||
# No recent games found
|
# No recent games found
|
||||||
self.games_list = []
|
self.games_list = []
|
||||||
self.current_game = None
|
self.current_game = None
|
||||||
logging.info("[NHL] No recent games found")
|
logging.info("[NHL] No recent games found for favorite teams")
|
||||||
|
else:
|
||||||
|
logging.warning("[NHL] No events found in ESPN API response")
|
||||||
|
|
||||||
# Check if it's time to switch games
|
# Check if it's time to switch games
|
||||||
if len(self.games_list) > 1 and (current_time - self.last_game_switch) >= self.game_display_duration:
|
if len(self.games_list) > 1 and (current_time - self.last_game_switch) >= self.game_display_duration:
|
||||||
@@ -519,6 +526,8 @@ class NHLRecentManager(BaseNHLManager):
|
|||||||
def display(self, force_clear: bool = False):
|
def display(self, force_clear: bool = False):
|
||||||
"""Display recent game information."""
|
"""Display recent game information."""
|
||||||
if not self.current_game:
|
if not self.current_game:
|
||||||
|
# Clear the display when there are no games
|
||||||
|
self.display_manager.clear()
|
||||||
return
|
return
|
||||||
super().display(force_clear) # Call parent class's display method
|
super().display(force_clear) # Call parent class's display method
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user