Commit Graph
2 Commits
Author SHA1 Message Date
FuelBoard Contributor bd3d3862ec Fix API base URL, rate-limit paging, background refresh; verify live against official API
- Base URL corrected to https://www.fuel-finder.service.gov.uk (the
  api.fuelfinder.service.gov.uk host in the portal's examples is stale —
  it does not resolve; www.fuel-finder... resolves to CloudFront and is
  what the live spec uses). Verified: /health now reports source=api,
  8,010 stations, 0 failures.
- Fuel Finder is strictly sequential (30 rpm per client, 429 on overlap):
  added FUEL_API_BATCH_SLEEP (default 4.0s) between pages ≈ 15 rpm.
- Stale-cache refresh moved off the request path into a background
  thread — a multi-minute rate-limited sync no longer blows the app's
  5s timeout; stale data is served while it catches up.
- Multiple diesel variants (B7_STANDARD, B7_PREMIUM, B10) now map to
  DIESEL as the MINIMUM price, so a premium price can't inflate the
  cheapest-diesel reference (CSV relay took first-wins; min is safer).
- Added B7_PREMIUM (underscore) to the fuel map — official key.
- scripts/run.sh now prefers the project venv (bare python3 missed
  uvicorn when run outside an activated env).
- Tests updated for min-diesel + B7_PREMIUM; 12/12 pass.
2026-08-12 15:50:08 +01:00
FuelBoard Contributor b315f4dc47 FuelBoard Relay API: official Fuel Finder API adapter (sibling of CSV relay)
- Talks to the OFFICIAL GOV.UK Fuel Finder API instead of the public CSV
  mirror: OAuth token (/api/v1/oauth/generate_access_token), batched
  paging (500/page via batch-number) over /api/v1/pfs and
  /api/v1/pfs/fuel-prices, joined on node_id.
- Price strings parsed to pence with pounds->pence correction (< 2.0);
  50-500p sane band keeps junk out of the cheapest reference.
- Fuel mapping: E5/E10 as-is; B7/B7_STANDARD/B7S/B7P/B10 -> DIESEL;
  HVO/SDV dropped (app tracks E5/E10/DIESEL only).
- lat/lng parsed from nested location strings.
- Output contract IDENTICAL to fuelboard-relay (/health + /api/v1/stations),
  so the app/widget/alerts work unchanged; switch = point app at :8789.
- CSV mirror kept as automatic fallback (FUEL_SOURCE=auto) so the full
  path is testable before GOV.UK One Login creds exist.
- 12 unit tests against documented API shapes (no network).
2026-08-12 15:34:57 +01:00