mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-15 10:03:31 +00:00
fix(display): Vegas excluded plugins always showing as checked (#332)
* fix(cache): check odds keys before generic live check in get_data_type_from_key Cache keys like odds_espn_basketball_nba_<id>_live contain both 'odds' and 'live'. The previous ordering matched the generic 'live' check first, returning 'sports_live' (30 s TTL) instead of the correct 'odds_live' (120 s TTL). This caused the ESPN odds API to be hit every 30 s per live game, frequently triggering the 3-second per-request timeout and returning no odds data. Moving the 'odds' check above the generic 'live' block restores the correct 120-second cache TTL for in-progress game odds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(display): use single-quoted HTML attributes for JSON hidden inputs Placing |tojson output (which contains double quotes) inside a double-quoted HTML attribute broke the attribute — browsers closed the attribute at the first inner quote, leaving JS with an empty or truncated value. JSON.parse then failed silently, leaving excluded=[] so all Vegas scroll plugins appeared checked (included) regardless of the actual excluded_plugins config. Switch to single-quoted HTML attributes so the JSON double quotes are valid inside the attribute value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
24
src/cache/cache_strategy.py
vendored
24
src/cache/cache_strategy.py
vendored
@@ -193,19 +193,21 @@ class CacheStrategy:
|
||||
Data type string for strategy lookup
|
||||
"""
|
||||
key_lower = key.lower()
|
||||
|
||||
# Odds data — checked FIRST because odds keys may also contain 'live'/'current'
|
||||
# (e.g. odds_espn_nba_game_123_live). The odds TTL (120s for live, 1800s for
|
||||
# upcoming) must win over the generic sports_live TTL (30s) to avoid hitting
|
||||
# the ESPN odds API every 30 seconds per game.
|
||||
if 'odds' in key_lower:
|
||||
# For live games, use shorter cache; for upcoming games, use longer cache
|
||||
if any(x in key_lower for x in ['live', 'current']):
|
||||
return 'odds_live' # Live odds change more frequently (120s TTL)
|
||||
return 'odds' # Regular odds for upcoming games (1800s TTL)
|
||||
|
||||
# Live sports data (only reached if key does NOT contain 'odds')
|
||||
# Odds data — checked before the generic 'live' block below because
|
||||
# live-odds cache keys (e.g. odds_espn_basketball_nba_<id>_live) contain
|
||||
# both 'odds' AND 'live'. Without this ordering the 'live' check below
|
||||
# would match first and return 'sports_live' (30 s TTL) instead of the
|
||||
# correct 'odds_live' (120 s TTL).
|
||||
if 'odds' in key_lower:
|
||||
if any(x in key_lower for x in ['live', 'current']):
|
||||
return 'odds_live' # Live odds change more frequently
|
||||
return 'odds' # Regular odds for upcoming games
|
||||
|
||||
# Live sports data
|
||||
if any(x in key_lower for x in ['live', 'current', 'scoreboard']):
|
||||
if 'soccer' in key_lower:
|
||||
return 'sports_live' # Soccer live data is very time-sensitive
|
||||
return 'sports_live'
|
||||
|
||||
# Weather data
|
||||
|
||||
@@ -380,8 +380,8 @@
|
||||
<!-- Plugin order list will be populated by JavaScript -->
|
||||
<p class="text-sm text-gray-500 italic">Loading plugins...</p>
|
||||
</div>
|
||||
<input type="hidden" id="vegas_plugin_order_value" name="vegas_plugin_order" value="{{ main_config.display.get('vegas_scroll', {}).get('plugin_order', [])|tojson }}">
|
||||
<input type="hidden" id="vegas_excluded_plugins_value" name="vegas_excluded_plugins" value="{{ main_config.display.get('vegas_scroll', {}).get('excluded_plugins', [])|tojson }}">
|
||||
<input type="hidden" id="vegas_plugin_order_value" name="vegas_plugin_order" value='{{ main_config.display.get("vegas_scroll", {}).get("plugin_order", [])|tojson }}'>
|
||||
<input type="hidden" id="vegas_excluded_plugins_value" name="vegas_excluded_plugins" value='{{ main_config.display.get("vegas_scroll", {}).get("excluded_plugins", [])|tojson }}'>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user