-
Notifications
You must be signed in to change notification settings - Fork 16
fix(SF2.0/UpcomingDepartures): Get scheduled and predicted other_stops #2854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(SF2.0/UpcomingDepartures): Get scheduled and predicted other_stops #2854
Conversation
a55dfbf to
8b0489a
Compare
3703a0d to
247158b
Compare
247158b to
945f281
Compare
|
|
||
| defp reject_timeless_predictions(predictions) do | ||
| predictions | ||
| defp end_of_trip?(%PredictedSchedule{schedule: schedule, prediction: prediction}) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: it's unclear from the code alone how "end of trip" means "no predicted or scheduled departure time" -- I suggest either adjusting the name of this function or adding an explanatory comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And there are a bunch of functions in this module at this point that could use explanatory comments, since the whole thing is becoming fairly complicated. I'll probably add more of those over the next few weeks as the behavior in this module settles down (those comments are very helpful, and also quite annoying to refactor around).
| defp trip_details(predictions_by_trip_id, trip_id, stop_id) do | ||
| other_stops = other_stops(predictions_by_trip_id |> Map.get(trip_id)) | ||
| defp trip_details(predicted_schedules_by_trip_id, trip_id, stop_id) do | ||
| other_stops = other_stops(predicted_schedules_by_trip_id |> Map.get(trip_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/question: This variable is technically all stops, I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, hum, yes.
I'm working on refactoring pretty much everything about trip details in an upcoming PR, so would it be okay to keep this for now, with the understanding that this is almost certainly going to get torn apart and redone pretty soon?
This fixes an issue present in Ye Olde Schedulle Finderre, as well as previous instances of this, where commuter rail trips would only be endowed with predictions for their first stop until they actually pulled out of the station, like 👇.
Now, instead of checking only schedules or only predictions, we check
predicted_scheduleswhich already has the schedules and predictions stitched together, in order to fallback to schedules when predictions are unavailable, even within a single trip:(Left: SF1.0 without the fix; Right: SF2.0 with the fix)
Asana Ticket: [SF/UD] CR: Use schedule data to fill in trip details when predictions are for a partial trip