mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-05-13 10:36:21 +02:00
* feat(trade): UN Comtrade strategic commodity flows seeder + RPC (#2045) * fix(trade): correct byYear overwrite bug and anomaliesOnly upstream flag Two bugs in the Comtrade flows feature: 1. seed-trade-flows.mjs: byYear Map used year alone as key. With flowCode=X,M the API returns both export and import records for the same year; the second record silently overwrote the first, causing incorrect val/wt and YoY calculations. Fix: key by `${flowCode}:${year}` so exports and imports are tracked separately and YoY is computed per flow direction. 2. list-comtrade-flows.ts: `if (!flows.length)` set upstreamUnavailable=true even when Redis data was present but all records were filtered out by anomaliesOnly=true. Fix: track dataFound separately and only set upstreamUnavailable when no Redis keys returned data. * fix(comtrade-flows): gold standard TTL, maxStaleMin, exit code, batch Redis fetch - health.js: maxStaleMin 1440→2880 (2× daily interval per gold standard) - seed-trade-flows.mjs: CACHE_TTL 86400→259200 (72h = 3× daily interval) - seed-trade-flows.mjs: process.exit(1)→0 to match seeder suite convention - list-comtrade-flows.ts: replace 30 getCachedJson calls with single getCachedJsonBatch pipeline
17 KiB
17 KiB