Work / Case study 005
Headway
Every Metro train, live.
- 98Metro stations, with every train live
- 82Ride On bus routes, by timetable
- 1 snapshot a minuteof every train, recorded for replay
01 — The problem
WMATA’s feed says where every train is, minute by minute, but not whether it’s late, and nobody tells you how the day actually went.
02 — The messy data
- Late stretch: Red Line, about 5 min late from 8:50 AM to 12:10 PM (worst 10 minutes: 7 min late).
- Late stretch: Silver Line, about 4 min late from 7:10 AM to 9:20 AM …
- Longest wait between trains: 30 min, Red Line toward Shady Grove, at 2:22 AM.
Saturday, Oct 17, from a day of one-minute snapshots
Red Line runs 5 min late for most of a Saturday morning
The Red Line was about 5 min late from 8:50 AM to 12:10 PM, with its worst 10 minutes at 7 min late. Weekend maintenance explains some of it: single tracking between Forest Glen and Silver Spring, with trains every 10 minutes.
03 — How it works
Sources
WMATA’s live train positions, arrival predictions and alerts, plus the Metro and Ride On timetables.
Every minute
A Cloudflare Worker saves a snapshot of every train to a D1 database.
3:30 AM: the logbook, with checks
Code works out the day’s numbers (late stretches, longest waits, alerts). That list is turned into a short logbook entry, and every number in it is checked against the list. After three failed tries, a plain template writes the entry instead.
Output
The site’s reliability view and the logbook line under the logo.
04 — Decisions worth noting
The code does the math; the writing only repeats it.
Nothing in the writing step computes, adds up, rounds or converts. Any number in the text that isn’t in the day’s facts, spelled out or not, means a retry.
Written for people to read.
The logbook is the one place a visitor reads a whole paragraph word for word, so it’s held to plain, short sentences and the same voice as the rest of the site.
The WMATA key never reaches your browser.
The site proxies WMATA’s feeds and caches them at the edge for 10 seconds, so more visitors don’t mean more calls to WMATA. It doesn’t re-serve WMATA’s API to other sites, which their terms forbid.
05 — What’s next
Live Ride On buses, if the county publishes a real-time feed. It hasn’t published one yet.