mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-26 01:24:59 +02:00
feat(economic): WoW price tracking + weekly cadence for BigMac & Grocery panels (#1974)
* feat(economic): add WoW tracking and fix plumbing for bigmac/grocery-basket panels Phase 1 — Fix Plumbing: - Adjust CACHE_TTL to 10 days (864000s) for bigmac and grocery-basket seeds - Align health.js SEED_META maxStaleMin to 10080 (7 days) for both - Add grocery-basket and bigmac to seed-health.js SEED_DOMAINS with intervalMin: 5040 - Refactor publish.ts writeSnapshot to accept advanceSeedMeta param; only advance seed-meta when fresh data exists (overallFreshnessMin < 120) - Add manual-fallback-only comment to seed-consumer-prices.mjs Phase 2 — Week-over-Week Tracking: - Add wow_pct field to BigMacCountryPrice and CountryBasket proto messages - Add wow_avg_pct, wow_available, prev_fetched_at to both response protos - Regenerate client/server TypeScript from updated protos - Add readCurrentSnapshot() helper + WoW computation to seed-bigmac.mjs and seed-grocery-basket.mjs; write :prev key via extraKeys - Update BigMacPanel.ts to show per-country WoW column and global avg summary - Update GroceryBasketPanel.ts to show WoW badge on total row and basket avg summary - Add .bm-wow-up, .bm-wow-down, .bm-wow-summary, .gb-wow CSS classes - Fix server handlers to include new WoW fields in fallback responses * fix(economic): guard :prev extraKey against null on first seed run; eliminate double freshness query in publish.ts * refactor(economic): address code review findings from PR #1974 - Extract readSeedSnapshot() into _seed-utils.mjs (DRY: was duplicated verbatim in seed-bigmac and seed-grocery-basket) - Add FRESH_DATA_THRESHOLD_MIN constant in publish.ts (replace magic 120) - Fix seed-consumer-prices.mjs contradictory JSDoc (remove stale "Deployed as: Railway cron service" line that contradicted manual-only warning) - Add i18n keys panels.bigmacWow / panels.bigmacCountry to en.json - Replace hardcoded "WoW" / "Country" with t() calls in BigMacPanel - Replace IIFE-in-ternary pattern with plain if blocks in BigMacPanel and GroceryBasketPanel (P2/P3 from code review) * fix(publish): gate advanceSeedMeta on any-retailer freshness, not average overallFreshnessMin is the arithmetic mean across all retailers, so with 1 fresh + 2 stale retailers the average can exceed 120 min and suppress seed-meta advancement even while fresh data is being published. Use retailers.some(r => r.freshnessMin < 120) to correctly implement "at least one retailer scraped within the last 2 hours."
This commit is contained in:
@@ -981,6 +981,13 @@ components:
|
||||
type: string
|
||||
upstreamUnavailable:
|
||||
type: boolean
|
||||
wowAvgPct:
|
||||
type: number
|
||||
format: double
|
||||
wowAvailable:
|
||||
type: boolean
|
||||
prevFetchedAt:
|
||||
type: string
|
||||
CountryBasket:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1002,6 +1009,9 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/GroceryItemPrice'
|
||||
wowPct:
|
||||
type: number
|
||||
format: double
|
||||
GroceryItemPrice:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1038,6 +1048,13 @@ components:
|
||||
type: string
|
||||
mostExpensiveCountry:
|
||||
type: string
|
||||
wowAvgPct:
|
||||
type: number
|
||||
format: double
|
||||
wowAvailable:
|
||||
type: boolean
|
||||
prevFetchedAt:
|
||||
type: string
|
||||
BigMacCountryPrice:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1062,6 +1079,9 @@ components:
|
||||
type: string
|
||||
available:
|
||||
type: boolean
|
||||
wowPct:
|
||||
type: number
|
||||
format: double
|
||||
GetNationalDebtRequest:
|
||||
type: object
|
||||
description: GetNationalDebtRequest requests national debt data for all countries.
|
||||
|
||||
Reference in New Issue
Block a user