mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
shorten live game update interval
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
"enabled": true,
|
||||
"test_mode": false,
|
||||
"update_interval_seconds": 300,
|
||||
"live_update_interval": 60,
|
||||
"live_update_interval": 15,
|
||||
"recent_update_interval": 3600,
|
||||
"upcoming_update_interval": 3600,
|
||||
"recent_game_hours": 48,
|
||||
|
||||
@@ -193,7 +193,25 @@ class BaseNHLManager:
|
||||
|
||||
def _fetch_data(self, date_str: str = None) -> Optional[Dict]:
|
||||
"""Fetch data using shared data mechanism."""
|
||||
return self._fetch_shared_data(date_str)
|
||||
# For live games, bypass the shared cache to ensure fresh data
|
||||
if isinstance(self, NHLLiveManager):
|
||||
try:
|
||||
url = ESPN_NHL_SCOREBOARD_URL
|
||||
params = {}
|
||||
if date_str:
|
||||
params['dates'] = date_str
|
||||
|
||||
response = requests.get(url, params=params)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
self.logger.info(f"[NHL] Successfully fetched live game data from ESPN API")
|
||||
return data
|
||||
except requests.exceptions.RequestException as e:
|
||||
self.logger.error(f"[NHL] Error fetching live game data from ESPN: {e}")
|
||||
return None
|
||||
else:
|
||||
# For non-live games, use the shared cache
|
||||
return self._fetch_shared_data(date_str)
|
||||
|
||||
def _load_fonts(self):
|
||||
"""Load fonts used by the scoreboard."""
|
||||
@@ -482,7 +500,7 @@ class NHLLiveManager(BaseNHLManager):
|
||||
"""Manager for live NHL games."""
|
||||
def __init__(self, config: Dict[str, Any], display_manager: DisplayManager):
|
||||
super().__init__(config, display_manager)
|
||||
self.update_interval = self.nhl_config.get("live_update_interval", 30) # 30 seconds for live games
|
||||
self.update_interval = self.nhl_config.get("live_update_interval", 15) # 15 seconds for live games
|
||||
self.no_data_interval = 300 # 5 minutes when no live games
|
||||
self.last_update = 0
|
||||
self.logger.info("Initialized NHL Live Manager")
|
||||
|
||||
Reference in New Issue
Block a user