feat: add Fast Lane wait times toggle on park pages
Build and Deploy / Build & Push (push) Successful in 1m3s
Build and Deploy / Build & Push (push) Successful in 1m3s
Join Fast Lane waits from the Six Flags /wait-times endpoint onto Queue-Times rides by name. A new toggle on the live ride panel swaps the shown wait to the Fast Lane number; regular waits and open status still come from Queue-Times. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -5,11 +5,14 @@ import { getCoasterSet } from "../../../lib/coaster-data";
|
||||
import { getTodayLocal, isWithinOperatingWindow } from "../../../lib/env";
|
||||
import { fetchLiveRides } from "../../../lib/scrapers/queuetimes";
|
||||
import { scrapeRidesForDay } from "../../../lib/scrapers/sixflags";
|
||||
import { fetchFastLaneWaits, lookupFastLane } from "../../../lib/scrapers/sixflags-waittimes";
|
||||
import { getDayData } from "../db/queries";
|
||||
import { TtlCache } from "../services/cache";
|
||||
import type { LiveRidesResult } from "../../../lib/scrapers/queuetimes";
|
||||
import type { FastLaneResult } from "../../../lib/scrapers/sixflags-waittimes";
|
||||
|
||||
const liveRidesCache = new TtlCache<LiveRidesResult | null>(5 * 60 * 1000);
|
||||
const fastLaneCache = new TtlCache<FastLaneResult | null>(5 * 60 * 1000);
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
@@ -41,6 +44,30 @@ app.get("/:id/rides", async (c) => {
|
||||
rides: liveRides.rides.map((r) => ({ ...r, isOpen: false, waitMinutes: 0 })),
|
||||
};
|
||||
}
|
||||
|
||||
// Join Fast Lane waits (Six Flags /wait-times) onto the Queue-Times rides by name.
|
||||
if (liveRides) {
|
||||
let fastLane = fastLaneCache.get(id);
|
||||
if (fastLane === null) {
|
||||
fastLane = await fetchFastLaneWaits(park.apiId).catch(() => null);
|
||||
if (fastLane) fastLaneCache.set(id, fastLane);
|
||||
}
|
||||
if (fastLane) {
|
||||
const fl = fastLane;
|
||||
liveRides = {
|
||||
...liveRides,
|
||||
rides: liveRides.rides.map((r) => {
|
||||
const match = lookupFastLane(r.name, fl);
|
||||
if (!match) return r;
|
||||
return {
|
||||
...r,
|
||||
hasFastLane: match.hasFastLane,
|
||||
fastLaneMinutes: r.isOpen ? match.fastLaneMinutes : null,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const isWeatherDelay =
|
||||
|
||||
Reference in New Issue
Block a user