Files
SixFlagsSuperCalendar/lib/ride-slug.ts
T
josh 4f838d99c1
Build and Deploy / Build & Push (push) Successful in 3m7s
feat: add per-ride history charts with wait time and uptime tracking
Adds a cron-driven sampler that snapshots Queue-Times waits and Six Flags
Fast Lane data every 5 minutes into a new ride_wait_samples table, and a
clickable per-ride detail page at /park/[id]/ride/[slug] with Today / 7d /
30d Recharts views plus a 30d uptime pill. Rides are keyed by Queue-Times'
stable qt_ride_id so renames don't fragment history. Samples store
pre-bucketed local_date and local_time in the park's IANA timezone so
aggregations are pure SQL and DST-safe.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 23:35:27 -04:00

32 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* URL-safe slug generator for ride names.
*
* Used as a secondary key on the `rides` table — the primary key is
* (park_id, qt_ride_id) so renames don't lose history. The slug is just
* for pretty URLs.
*
* Steps:
* 1. NFD-normalize to split accented letters into base + combining mark
* 2. Strip combining marks (diacritics, U+0300U+036F)
* 3. Strip trademark symbols
* 4. Lowercase
* 5. Replace any non-alphanumeric run with a single hyphen
* 6. Trim leading/trailing hyphens
*
* Examples:
* "X²" → "x"
* "Lex Luthor: Drop of Doom" → "lex-luthor-drop-of-doom"
* "Catwoman's Whip" → "catwoman-s-whip"
* "Façade" → "facade"
* "Batman™ The Ride" → "batman-the-ride"
*/
export function slugifyRideName(name: string): string {
return name
.normalize("NFD")
.replace(/[̀-ͯ]/g, "")
.replace(/[™®©]/g, "")
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
}