1.3 KiB
| id | type | title | tags | importance | confidence | created | updated | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| fbc3a7f4-f50a-4556-bcca-fd49a268a82f | fix | Fix: ScorecardTracker stale data - load_data() on every read |
|
0.7 | 0.8 | 2026-02-20T20:06:02.824409+00:00 | 2026-02-20T20:06:02.824409+00:00 |
Fix: ScorecardTracker Stale Data
Problem
The background task (LiveScorebugTracker) and the /publish-scorecard command each create their own ScorecardTracker instance. Publishing writes to data/scorecards.json through the command's instance, but the background task's instance had stale in-memory data and never saw the updates.
Root Cause
ScorecardTracker loaded data once at construction time and kept it in memory. Multiple instances do not share state, so one instance's writes were invisible to others.
Fix
Added self.load_data() at the start of get_scorecard() and get_all_scorecards() in commands/gameplay/scorecard_tracker.py so they always read fresh data from disk on every call.
Why It's Safe
The JSON file (data/scorecards.json) is small, so the disk read overhead is negligible. This is a simple, correct fix without needing to introduce shared state or a singleton.
File
commands/gameplay/scorecard_tracker.py
Related
Closes issue #40. Branch: fix/scorebug-bugs.