Compare commits

...

2 Commits

2 changed files with 34 additions and 0 deletions

View File

@ -226,3 +226,7 @@ Files
- **Summary:** Commits made: 1
- fix: batch quick-wins — 4 issues resolved (closes #37, #27, #25, #38)
Files
## 14:06 - Fix: ScorecardTracker stale data - load_data() on every read
- **Type:** fix
- **Tags:** major-domo, scorebug, scorecard-tracker, fix, stale-data, discord-bot

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