perf(SF2.0): Stream predictions to UpcomingDepartures.Server instead of polling#3247
Merged
joshlarson merged 46 commits intoJun 10, 2026
Merged
Conversation
…Departures.Server`
…hedule-data-structure
…ons/1` and `update_schedules/2`
thecristen
approved these changes
Jun 10, 2026
thecristen
left a comment
Collaborator
There was a problem hiding this comment.
I'm feeling good about this and all the different bugs we've tackled on it today. I'd like to give this a whirl.
Merged
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.
Scope
Asana Ticket: 📅🔎🎭 Extract prediction fetching out of Upcoming Departures GenServer
Implementation
(Don't bother looking at this commit-by-commit - the commits are kind of a mess - sorry!)
Dotcom.PredictionsThis introduces a new namespace with the following modules:
Dotcom.Predictions.Managersubscribeorunsubscribein order to receive messages when predictions data is added or modified. When a process subscribes to a predictions stream, it creates anEventSupervisorthat (see below) gathers up predictions events and sends them back to its subscribers.Dotcom.Predictions.EventSupervisorServerSentEventStagethat hooks into the V3 API to get 🥟steamed🥟 messages, and anEventBroadcaster.Dotcom.Predictions.EventBroadcasterManager.Other Changes
There are other oddball changes in this PR:
Dotcom.UpcomingDepartures.Server@predictions_repo.DotcomWeb.Live.UpcomingDeparturesLive:loading?state fromUpcomingDepartures.Server.PredictedSchedule.CollectionPredictions.StreamParserPredictions.Parser.Screenshots
Enjoy this side-by-side of local and prod for Green Line at Fenway Westbound, on either side of a photo of a Green Line train at Fenway going Westbound.
You may notice that local has one timestamp different from prod - that's because by virtue of streaming, this branch responds more quickly to updates than prod does, hence local showing a lower number of minutes remaining than prod (prod updated to also show 17 about 3 seconds after I took ☝️ screenshot).
How to test
Visit any departures page and verify that it loads upcoming departures as expected.
You won't notice much in the way of visual changes, but you might notice that this branch responds to changes in a snappier way.