Skip to content

Commit

Permalink
Add filter for determining if prediction has passed
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Aug 22, 2024
1 parent 7fe2370 commit 135c50a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/predictions/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Predictions.Predictions do
|> Stream.map(&prediction_from_update(&1, current_time))
|> Enum.reject(
&((is_nil(&1.seconds_until_arrival) and is_nil(&1.seconds_until_departure)) or
(&1.seconds_until_departure && &1.seconds_until_departure < -10))
has_departed?(&1))
)

vehicles_running_revenue_trips =
Expand Down Expand Up @@ -163,4 +163,10 @@ defmodule Predictions.Predictions do
true
end
end

@spec has_departed?(Predictions.Prediction.t()) :: boolean()
defp has_departed?(prediction) do
prediction.seconds_until_departure && prediction.seconds_until_departure < 0 &&
not prediction.stopped_at_predicted_stop?
end
end

0 comments on commit 135c50a

Please sign in to comment.