diff --git a/lib/predictions/last_trip.ex b/lib/predictions/last_trip.ex index 23d5d1987..dcc005b07 100644 --- a/lib/predictions/last_trip.ex +++ b/lib/predictions/last_trip.ex @@ -2,7 +2,18 @@ defmodule Predictions.LastTrip do defp get_running_trips(predictions_feed) do predictions_feed["entity"] |> Stream.map(& &1["trip_update"]) - |> Enum.reject(&(&1["trip"]["schedule_relationship"] == "CANCELED")) + |> Stream.filter( + &(&1["trip"]["route_id"] in [ + "Red", + "Blue", + "Orange", + "Green-B", + "Green-C", + "Green-D", + "Green-E", + "Mattapan" + ] and &1["trip"]["schedule_relationship"] != "CANCELED") + ) end def get_last_trips(predictions_feed) do diff --git a/lib/predictions/predictions.ex b/lib/predictions/predictions.ex index 26ba58570..38d98c95f 100644 --- a/lib/predictions/predictions.ex +++ b/lib/predictions/predictions.ex @@ -29,8 +29,9 @@ defmodule Predictions.Predictions do end) |> Stream.map(&prediction_from_update(&1, current_time)) |> Enum.reject( - &(is_nil(&1.seconds_until_arrival) and is_nil(&1.seconds_until_departure) and - is_nil(&1.seconds_until_passthrough)) + &((is_nil(&1.seconds_until_arrival) and is_nil(&1.seconds_until_departure) and + is_nil(&1.seconds_until_passthrough)) or + (&1.seconds_until_departure && &1.seconds_until_departure < 0)) ) vehicles_running_revenue_trips = @@ -99,7 +100,7 @@ defmodule Predictions.Predictions do direction_id: direction_id, seconds_until_arrival: max(0, seconds_until_arrival), arrival_certainty: stop_time_update["arrival"]["uncertainty"], - seconds_until_departure: max(0, seconds_until_departure), + seconds_until_departure: seconds_until_departure, departure_certainty: stop_time_update["departure"]["uncertainty"], seconds_until_passthrough: max(0, seconds_until_passthrough), schedule_relationship: