Use TransitMatters benchmark as replacement for MBTA on travel-time chart#1157
Open
devinmatte wants to merge 3 commits intomainfrom
Open
Use TransitMatters benchmark as replacement for MBTA on travel-time chart#1157devinmatte wants to merge 3 commits intomainfrom
devinmatte wants to merge 3 commits intomainfrom
Conversation
Backend: read the new Benchmarks-tm/traveltimes/{Color}.json produced by
mbta-performance (cached per-color in-process) and attach
tm_benchmark_travel_time_sec to each travel-time record.
Frontend: render a dashed TM-red line on the single-day travel-time chart at
per-point min(tm_historic, mbta_benchmark), so when MBTA is faster the two
lines overlap and the TM line visually disappears. When a trip beats both
benchmarks the dot is surrounded by a subtle pulsing emerald ring (with a
2s pause between pulses to keep the animation cheap). Rename the existing
"Benchmark MBTA" label to "MBTA Benchmark" for consistency.
Legend gains "TransitMatters benchmark" and "Beat both benchmarks" entries,
only shown when tm_benchmark data is present (rapid transit only).
After design review, drop the dual-line / shiny-dot design. Instead of rendering a second TransitMatters line, the single benchmark band now uses the TM historical value per-point where we have >= 1 year of data, and falls back to the MBTA scheduled value otherwise. Dot colors (green/yellow/ red/purple) are computed against whichever benchmark applies to that point. Legend header now says "Compare to ... benchmark:" (no longer "MBTA benchmark:") with a small emerald info pill appearing beside it when the chart has any TM-benchmark points, carrying a tooltip that explains what TransitMatters benchmarks are and when they apply. Removed the "TransitMatters benchmark" and "Beat both benchmarks" legend rows, the dashed red line, the gold/emerald dot borders, and the shinyPoints animation plugin.
- Tooltip shows "TransitMatters Benchmark" or "MBTA Benchmark" per point based on which source was used (a TM-mode chart may still fall back to MBTA on pairs with insufficient history). - Dataset label switches accordingly so Chart.js's built-in legend names the correct benchmark. - Departure-from-normal text says "over benchmark" when the chart uses the TM benchmark, and keeps the existing "over schedule" wording everywhere else. - Legend header swaps "MBTA benchmark:" for "TransitMatters benchmark:" when the TM value is in use — no info pill, no other layout changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Where we have enough historical data, the travel-time chart now uses the TransitMatters benchmark in place of the MBTA scheduled benchmark — one band, not two. Dot colors (on-time / 25%+ off / etc.) are computed against whichever benchmark applies to that point. When TM data is missing (bus, CR, a stop pair with <1 year of history), the chart transparently falls back to the MBTA value.
The legend header swaps "MBTA benchmark:" for "TransitMatters benchmark:" when the chart has any TM-derived points. Tooltip labels each point's benchmark honestly — a TM-mode chart can still show "MBTA Benchmark" on individual points that fell back. Departure-from-normal text switches from "25%+ over schedule" to "25%+ over benchmark" on TM-mode charts.
Depends on mbta-performance #85 producing the per-line JSON files this reads.
Changes
server/chalicelib/tm_benchmarks.pylazily loadsBenchmarks-tm/traveltimes/{Color}.jsonper line (module-level cache, refreshed when the Lambda container recycles).s3_historical.travel_times()attachestm_benchmark_travel_time_secto each record. Existing policy already covers the new S3 prefix.tm[i] ?? mbta[i]. That value drives both the gray benchmark band and the dot-color thresholds. Dataset label swaps between "TransitMatters Benchmark" and "MBTA Benchmark" so native Chart.js elements name the right source.Scope
Travel times, rapid transit only. Other single-day charts (headways, dwells) and non-rapid-transit routes keep the MBTA benchmark unchanged, including the "over schedule" tooltip wording.
Test plan