store: Decision: Auto-sync on dashboard mount when all entities stale >24h

This commit is contained in:
Cal Corum 2026-03-01 20:09:10 -06:00
parent 618171a736
commit 0f6f1ece3b

View File

@ -0,0 +1,32 @@
---
id: 346c5a34-3fed-44ff-832a-b0c9eb42ca88
type: decision
title: "Decision: Auto-sync on dashboard mount when all entities stale >24h"
tags: [sba-scouting, rust, sync, dashboard, decision, auto-sync]
importance: 0.6
confidence: 0.8
created: "2026-03-02T02:09:10.166132+00:00"
updated: "2026-03-02T02:09:10.166132+00:00"
---
# Auto-Sync on Dashboard Mount: Design Decision
## Context
sba-scouting Rust TUI — dashboard screen loads sync statuses from the DB on mount.
## Decision
After sync statuses load (in `SyncStatusesLoaded` handler), automatically trigger a full sync if ALL entity types (teams, players, transactions) have `last_sync` older than 24 hours OR have never been synced.
## Rationale
- Avoids stale data on first launch of the day without requiring manual user action
- "All entities" check prevents partial re-sync when only one type is fresh
- Only fires on dashboard mount (when statuses load), not on every navigation to dashboard
## Implementation
- Check fires in `DashboardState::handle_message()` inside the `SyncStatusesLoaded` arm
- Required adding `settings: &Settings` parameter to `handle_message()` to pass to `trigger_sync()`
- Standings use a separate `standings_cache` table with their own refresh mechanism — they do NOT participate in this check
## Scope Limits
- Does not affect standings cache
- Does not re-trigger if user navigates away and back (statuses only load once on mount)