Files
fuelboard/scripts/refresh_bundled_dump.sh
T
FuelBoard Contributor 366e21a1b4 P0: live provider chain — GitHub mirror primary, relay fallback, bundled dump last resort + app telemetry beacon
- MirrorFuelProvider: fetches CURRENT prices from raw.githubusercontent
  (latest.json pointer → history/<day>.json full dump), app-group day-cache
  so the ~2.8 MB dump is re-downloaded only when the mirror pushes a new day
- LiveChainProvider: full path (app refresh) GitHub → relay; focused path
  (background alert checks) relay-first so alerts never pull the full dump
  over mobile data; records which leg served for About + telemetry
- FuelBeacon: fire-and-forget X-Client app ping to the relay's existing
  widget-diag route (zero relay changes) — attribution + cadence on-LAN,
  silent skip off-LAN is the reachability datum; /stats app-hit spike =
  GitHub path failing
- Bundled dump: FuelBoardDump dataset (real 2026-08-15 snapshot, 8,022
  stations) + BundledDumpProvider + scripts/refresh_bundled_dump.sh —
  no-network last resort replaces the demo sample set
- ContentView: About meta from the chain; catch falls back cached → bundled
  → sample
- 89 tests (6 new: chain order x4, cache decision, beacon URL); Release
  build green; beacon route verified against the live relay (204 + logged)
2026-08-15 13:00:24 +01:00

21 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Refresh the bundled fallback dump (FuelBoardDump dataset) from the GitHub
# mirror — run before a Release build so the IPA carries the freshest REAL
# snapshot (the app's no-network last resort). Idempotent: skips when the
# bundled dump already carries the mirror's data_updated stamp.
set -euo pipefail
cd "$(dirname "$0")/.."
TARGET="FuelBoard/Assets.xcassets/FuelBoardDump.dataset/fuelboard_dump.json"
RAW="https://raw.githubusercontent.com/aptonline/fuelboard-data/main"
LATEST="$(curl -fsSL "$RAW/latest.json")"
DAY="$(printf '%s' "$LATEST" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("available_to") or d.get("date") or "")')"
UPD="$(printf '%s' "$LATEST" | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("data_updated") or "")')"
if [ -z "$DAY" ]; then echo "no snapshot day in latest.json" >&2; exit 1; fi
if [ -f "$TARGET" ] && grep -q "\"data_updated\": \"$UPD\"" "$TARGET"; then
echo "bundled dump already current ($DAY, $UPD)"
exit 0
fi
echo "fetching history/$DAY.json ($UPD)…"
curl -fsSL "$RAW/history/$DAY.json" -o "$TARGET"
echo "updated $TARGET$DAY"