store: Fix: ScorecardTracker stale data - load_data() on every read

This commit is contained in:
Cal Corum 2026-02-20 14:06:02 -06:00
parent 2ac84faaf1
commit aca54f872a

View File

@ -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`.