-
Notifications
You must be signed in to change notification settings - Fork 11
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(PredictionsChannel): filter out past predictions #2229
Conversation
# Exercise | ||
PredictionsChannel.handle_info({:new_predictions, predictions}, socket) | ||
|
||
[_past_prediction | expected_predictions] = predictions |
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.
[_past_prediction | expected_predictions] = predictions | |
expected_predictions = [now, future] |
Not a huge deal, but I'm more in favor of being super explicit about exactly what we expect, rather than having to reason about what's in the predictions
array.
@@ -61,4 +62,8 @@ defmodule DotcomWeb.PredictionsChannel do | |||
Route.subway?(prediction.route.type, prediction.route.id) && | |||
prediction.schedule_relationship in [:cancelled, :skipped] | |||
end | |||
|
|||
defp in_future_seconds?(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.
defp in_future_seconds?(prediction) do | |
defp in_future?(prediction) do |
Nit: I don't think the fact that it's in seconds really matters?
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.
I made two (kind of nit-picky) comments that I'd be interested in your thoughts on, but IMO neither one blocks approval.
Summary of changes
Asana Ticket: Fix: Extraneous <1 minute predictions appearing on Stop Pages
Some facts:
Filtering the predictions here in
DotcomWeb.PredictionsChannel
, right before we publish the predictions to stop pages, seems to work ok. My guess is that this logic wasn't included previously because we thought (a) we'd get timely "remove" events from the streaming predictions or (b) something else in our logic would filter these out before making it to the UI.