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.
This commit is contained in:
+7
-5
@@ -1,9 +1,11 @@
|
||||
# Copy to .env and fill in — NEVER commit .env
|
||||
# Copy of .env.example with REAL credentials — NEVER commit this file.
|
||||
# .gitignore line 1 excludes it; git check-ignore -v .env confirms.
|
||||
FUEL_API_CLIENT_ID=
|
||||
FUEL_API_CLIENT_SECRET=
|
||||
FUEL_API_TOKEN_URL=https://api.fuelfinder.service.gov.uk/api/v1/oauth/generate_access_token
|
||||
FUEL_API_PFS_URL=https://api.fuelfinder.service.gov.uk/api/v1/pfs
|
||||
FUEL_API_PRICES_URL=https://api.fuelfinder.service.gov.uk/api/v1/pfs/fuel-prices
|
||||
FUEL_API_BASE=https://www.fuel-finder.service.gov.uk
|
||||
FUEL_API_TOKEN_URL=https://www.fuel-finder.service.gov.uk/api/v1/oauth/generate_access_token
|
||||
FUEL_API_PFS_URL=https://www.fuel-finder.service.gov.uk/api/v1/pfs
|
||||
FUEL_API_PRICES_URL=https://www.fuel-finder.service.gov.uk/api/v1/pfs/fuel-prices
|
||||
FUEL_CACHE_TTL=300
|
||||
FUEL_API_BATCH_SLEEP=4.0
|
||||
FUEL_RELAY_PORT=8789
|
||||
# FUEL_SOURCE=auto # auto (API if creds, CSV fallback) | csv | api
|
||||
|
||||
Reference in New Issue
Block a user