|
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The account_snapshot cache fed /networth, /networth/history, and
/scenarios/{id}/progress. No CronJob populated it, so the cache had
drifted ~18 days behind the wealthfolio_sync mirror (last refresh
2026-05-09 via manual kubectl exec; Grafana reads wf_sync directly
and stayed fresh).
Switch to lazy refresh on read: each request to those endpoints now
checks MAX(account_snapshot.snapshot_date) — if it's older than
NETWORTH_CACHE_TTL_DAYS (default 1), pull fresh rows from wf_sync via
read_account_snapshots_from_pg and upsert. Idempotent under
concurrency (existing ON CONFLICT DO UPDATE).
Plumbing:
- Add get_wf_sync_session dependency that yields None when the wf_sync
factory isn't wired (keeps existing tests' behaviour: no refresh
attempted, they continue to seed account_snapshot directly).
- Wire wf_sync engine + session_factory in app.lifespan when
WEALTHFOLIO_SYNC_DB_CONNECTION_STRING is set.
- Centralise the staleness check in refresh_account_snapshots_if_stale.
Tests:
- 271 existing tests still green.
- Three new tests in test_api_networth_refresh.py covering: empty cache
triggers refresh, stale cache triggers refresh, fresh cache skips
refresh (asserts the wf_sync value is NOT served).
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| conftest.py | ||
| test_actualbudget.py | ||
| test_api_cashflow.py | ||
| test_api_life_events_goals.py | ||
| test_api_networth.py | ||
| test_api_networth_refresh.py | ||
| test_api_progress.py | ||
| test_api_scenarios.py | ||
| test_api_simulate.py | ||
| test_api_spending.py | ||
| test_api_spending_profile.py | ||
| test_api_year_stats.py | ||
| test_cli.py | ||
| test_col.py | ||
| test_db_schema.py | ||
| test_e2e.py | ||
| test_flex_spending.py | ||
| test_goals_eval.py | ||
| test_income_streams.py | ||
| test_ingest_wealthfolio_pg.py | ||
| test_life_events.py | ||
| test_reporters_pg.py | ||
| test_returns.py | ||
| test_returns_wealthfolio.py | ||
| test_scenarios.py | ||
| test_simulator.py | ||
| test_simulator_col_integration.py | ||
| test_simulator_events.py | ||
| test_simulator_fixed_rates.py | ||
| test_simulator_flex.py | ||
| test_spending_plan.py | ||
| test_strategies.py | ||
| test_tax_base.py | ||
| test_tax_other_regimes.py | ||
| test_tax_uk.py | ||