v3: PostgreSQL backend — 20K rows seeded, server-side SQL filtering

- Added PostgreSQL 16 Alpine service to Docker Swarm stack
- db.py: schema for 17 tables, auto-seed from jv_data.json on first boot
- /api/dashboard/data?start=&end= — server-side SQL filtering
  All Time: 0.43s (was 4MB JSON download stuck loading)
  Filtered (12mo): 0.20s with ~90% less data transferred
- Dashboard HTML patched: calls API instead of static JSON
- Integer casting for IsNewCustomer/HasDiscount/IsFreeShipping
- Advisory lock prevents race condition during parallel worker startup
- Returning Revenue now shows correctly: £14.5M (75% of total)
This commit is contained in:
2026-03-02 20:24:15 +08:00
parent 734142cf8f
commit 3f2b6b6188
5 changed files with 688 additions and 17 deletions

View File

@@ -3,3 +3,4 @@ gunicorn==23.0.0
requests==2.32.3
beautifulsoup4==4.13.3
google-genai==1.5.0
psycopg2-binary==2.9.10