Skip to content
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

increase red line gap filtering #676

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/signs/utilities/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ defmodule Signs.Utilities.Predictions do
# cause some predictions to not show up until right before they leave the
# terminal. This makes it appear that the next train will be much later than
# it is. At stations near Ashmont and Braintree, we're discarding any
# predictions following a gap of more than 18 minutes from the previous one,
# predictions following a gap of more than 21 minutes from the previous one,
# since this is a reasonable indicator of this problem.
defp filter_large_red_line_gaps([first | _] = predictions)
when first.stop_id in ~w(70105 Braintree-01 Braintree-02 70104 70102 70100 70094 70092 70090 70088) do
[%{seconds_until_departure: 0} | predictions]
|> Enum.chunk_every(2, 1, :discard)
|> Enum.take_while(fn [prev, current] ->
current.seconds_until_departure - prev.seconds_until_departure < 18 * 60
current.seconds_until_departure - prev.seconds_until_departure < 21 * 60
end)
|> Enum.map(&List.last/1)
end
Expand Down
Loading