From bde189eec2f3ba9c7c0e82cc50649dd26aa22c2a Mon Sep 17 00:00:00 2001 From: ChuckBuilds <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 24 Apr 2025 15:22:45 -0500 Subject: [PATCH] added espn api logging --- src/mlb_manager.py | 17 +++++++++++++++-- src/stock_manager.py | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mlb_manager.py b/src/mlb_manager.py index 101e32cb..9dd8ca55 100644 --- a/src/mlb_manager.py +++ b/src/mlb_manager.py @@ -217,6 +217,8 @@ class BaseMLBManager: response.raise_for_status() data = response.json() + self.logger.debug(f"Raw API response: {data}") # Log raw response + games = {} for event in data.get('events', []): @@ -228,6 +230,11 @@ class BaseMLBManager: home_team = next(c for c in competitors if c['homeAway'] == 'home') away_team = next(c for c in competitors if c['homeAway'] == 'away') + # Log team abbreviations we're getting + home_abbr = home_team['team']['abbreviation'] + away_abbr = away_team['team']['abbreviation'] + self.logger.info(f"Found game: {away_abbr} @ {home_abbr} (Status: {status})") + # Get game state information if status == 'in': # For live games, get detailed state @@ -255,8 +262,8 @@ class BaseMLBManager: bases_occupied = [False, False, False] games[game_id] = { - 'away_team': away_team['team']['abbreviation'], - 'home_team': home_team['team']['abbreviation'], + 'away_team': away_abbr, + 'home_team': home_abbr, 'away_score': away_team['score'], 'home_score': home_team['score'], 'status': status, @@ -268,6 +275,12 @@ class BaseMLBManager: 'start_time': event['date'] } + # Log what teams we're looking for vs what we found + self.logger.info(f"Looking for favorite teams: {self.favorite_teams}") + found_teams = set([game['home_team'] for game in games.values()] + + [game['away_team'] for game in games.values()]) + self.logger.info(f"Found teams in API response: {found_teams}") + # Cache the results with different expiration times based on game status cache_duration = 300 # 5 minutes for live games if not any(game['status'] == 'in' for game in games.values()): diff --git a/src/stock_manager.py b/src/stock_manager.py index 40a35aa8..11026d4d 100644 --- a/src/stock_manager.py +++ b/src/stock_manager.py @@ -479,7 +479,7 @@ class StockManager: # Calculate chart dimensions chart_width = int(width // 2.5) # Reduced from width//2.5 to prevent overlap chart_height = height // 1.5 - chart_x = width - chart_width - 4 # 14px margin from right edge + chart_x = width - chart_width - 4 # 4px margin from right edge chart_y = (height - chart_height) // 2 # Find min and max prices for scaling