From aca54f872a6115dc21a4509f04cae616f5893550 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 20 Feb 2026 14:06:02 -0600 Subject: [PATCH] store: Fix: ScorecardTracker stale data - load_data() on every read --- ...ale-data-load-data-on-every-read-fbc3a7.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 graph/fixes/fix-scorecardtracker-stale-data-load-data-on-every-read-fbc3a7.md diff --git a/graph/fixes/fix-scorecardtracker-stale-data-load-data-on-every-read-fbc3a7.md b/graph/fixes/fix-scorecardtracker-stale-data-load-data-on-every-read-fbc3a7.md new file mode 100644 index 00000000000..37086faaf81 --- /dev/null +++ b/graph/fixes/fix-scorecardtracker-stale-data-load-data-on-every-read-fbc3a7.md @@ -0,0 +1,30 @@ +--- +id: fbc3a7f4-f50a-4556-bcca-fd49a268a82f +type: fix +title: "Fix: ScorecardTracker stale data - load_data() on every read" +tags: [major-domo, scorebug, scorecard-tracker, fix, stale-data, discord-bot] +importance: 0.7 +confidence: 0.8 +created: "2026-02-20T20:06:02.824409+00:00" +updated: "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`.