Seed historical net worth snapshots and trigger live price sync on demo startup

- seed.py: adds 30 weekly NetWorthSnapshot rows (Sep 2025 → Apr 2026) so the
  Net Worth chart has full history on first boot, not just today's value
- main.py: fires price_sync_job and fx_sync_job in the background immediately
  after the scheduler starts in demo mode, so portfolio valuations are live
  from the moment the container becomes healthy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-04-23 22:47:44 +00:00
parent 48c9e1acab
commit 664b530136
2 changed files with 63 additions and 1 deletions

View file

@ -51,6 +51,15 @@ async def lifespan(app: FastAPI):
from app.workers.scheduler import start_scheduler, stop_scheduler
await start_scheduler()
# Demo: sync live prices and FX rates immediately so portfolio values are fresh
if settings.is_demo:
import asyncio
from app.workers.price_sync import price_sync_job
from app.workers.fx_sync import fx_sync_job
asyncio.ensure_future(price_sync_job())
asyncio.ensure_future(fx_sync_job())
logger.info("demo_background_sync_queued")
logger.info("startup_complete", env=settings.environment)
yield