From b9c3754378dadf6366fdd77e2cba98616ac9c5bf Mon Sep 17 00:00:00 2001 From: Brett Heath-Wlaz Date: Fri, 1 Nov 2024 11:54:49 -0400 Subject: [PATCH] defer crowding and new cars calculation until it's needed (#838) --- lib/content/audio/approaching.ex | 6 +- lib/content/audio/train_is_arriving.ex | 4 +- lib/content/message/predictions.ex | 144 +-------------------- lib/pa_ess/utilities.ex | 17 +++ lib/signs/utilities/audio.ex | 18 +-- lib/signs/utilities/crowding.ex | 94 ++++++++++++++ lib/signs/utilities/predictions.ex | 4 +- test/content/messages/predictions_test.exs | 54 +++----- test/signs/realtime_test.exs | 10 +- 9 files changed, 156 insertions(+), 195 deletions(-) create mode 100644 lib/signs/utilities/crowding.ex diff --git a/lib/content/audio/approaching.ex b/lib/content/audio/approaching.ex index 62c1008d..9449040e 100644 --- a/lib/content/audio/approaching.ex +++ b/lib/content/audio/approaching.ex @@ -20,15 +20,15 @@ defmodule Content.Audio.Approaching do crowding_description: {atom(), atom()} | nil } - def from_message(%Message.Predictions{} = message, include_crowding?) do + def from_message(%Message.Predictions{} = message, crowding_description, new_cars?) do [ %__MODULE__{ destination: message.destination, trip_id: message.prediction.trip_id, platform: Content.Utilities.stop_platform(message.prediction.stop_id), route_id: message.prediction.route_id, - new_cars?: message.new_cars?, - crowding_description: if(include_crowding?, do: message.crowding_description) + new_cars?: new_cars?, + crowding_description: crowding_description } ] end diff --git a/lib/content/audio/train_is_arriving.ex b/lib/content/audio/train_is_arriving.ex index 1f4856ea..e8b1434d 100644 --- a/lib/content/audio/train_is_arriving.ex +++ b/lib/content/audio/train_is_arriving.ex @@ -18,14 +18,14 @@ defmodule Content.Audio.TrainIsArriving do crowding_description: {atom(), atom()} | nil } - def from_message(%Message.Predictions{} = message, include_crowding? \\ false) do + def from_message(%Message.Predictions{} = message, crowding_description) do [ %__MODULE__{ destination: message.destination, trip_id: message.prediction.trip_id, platform: Content.Utilities.stop_platform(message.prediction.stop_id), route_id: message.prediction.route_id, - crowding_description: if(include_crowding?, do: message.crowding_description) + crowding_description: crowding_description } ] end diff --git a/lib/content/message/predictions.ex b/lib/content/message/predictions.ex index e4ad85d9..45838875 100644 --- a/lib/content/message/predictions.ex +++ b/lib/content/message/predictions.ex @@ -25,10 +25,7 @@ defmodule Content.Message.Predictions do :prediction, :station_code, :zone, - new_cars?: false, - terminal?: false, - crowding_data_confidence: nil, - crowding_description: nil + terminal?: false ] @type t :: %__MODULE__{ @@ -36,17 +33,13 @@ defmodule Content.Message.Predictions do minutes: integer() | :boarding | :arriving | :approaching, approximate?: boolean(), prediction: Predictions.Prediction.t(), - new_cars?: boolean(), station_code: String.t() | nil, zone: String.t() | nil, - terminal?: boolean(), - crowding_data_confidence: :high | :low | nil, - crowding_description: {atom(), atom()} | nil + terminal?: boolean() } - @spec non_terminal(Predictions.Prediction.t(), String.t(), String.t(), Signs.Realtime.t()) :: - t() | nil - def non_terminal(prediction, station_code, zone, sign) do + @spec non_terminal(Predictions.Prediction.t(), String.t(), String.t()) :: t() + def non_terminal(prediction, station_code, zone) do # e.g., North Station which is non-terminal but has trips that begin there predicted_time = prediction.seconds_until_arrival || prediction.seconds_until_departure @@ -63,27 +56,18 @@ defmodule Content.Message.Predictions do true -> compute_minutes(predicted_time, certainty) end - {crowding_data_confidence, crowding_description} = - if Signs.Utilities.SourceConfig.multi_source?(sign.source_config), - do: {nil, nil}, - else: do_crowding(prediction, sign) - %__MODULE__{ destination: Content.Utilities.destination_for_prediction(prediction), minutes: minutes, approximate?: approximate?, prediction: prediction, - new_cars?: sign.location_engine.for_vehicle(prediction.vehicle_id) |> new_cars?(), station_code: station_code, - zone: zone, - crowding_data_confidence: crowding_data_confidence, - crowding_description: crowding_description + zone: zone } end - @spec terminal(Predictions.Prediction.t(), String.t(), String.t(), Signs.Realtime.t()) :: - t() | nil - def terminal(prediction, station_code, zone, sign) do + @spec terminal(Predictions.Prediction.t(), String.t(), String.t()) :: t() + def terminal(prediction, station_code, zone) do stopped_at? = prediction.stops_away == 0 {minutes, approximate?} = @@ -98,7 +82,6 @@ defmodule Content.Message.Predictions do minutes: minutes, approximate?: approximate?, prediction: prediction, - new_cars?: sign.location_engine.for_vehicle(prediction.vehicle_id) |> new_cars?(), station_code: station_code, zone: zone, terminal?: true @@ -115,119 +98,6 @@ defmodule Content.Message.Predictions do end end - defp do_crowding(prediction, sign) when prediction.route_id in ["Orange"] do - case sign.location_engine.for_vehicle(prediction.vehicle_id) do - %Locations.Location{} = location -> - {calculate_crowding_data_confidence(prediction, location), - get_crowding_description(location.multi_carriage_details)} - - _ -> - {nil, nil} - end - end - - defp do_crowding(_, _), do: {nil, nil} - - defp calculate_crowding_data_confidence(prediction, location) - when location.stop_id == prediction.stop_id do - if location.status in [:incoming_at, :in_transit_to], - do: :high, - else: :low - end - - defp calculate_crowding_data_confidence(_prediction, _location), do: nil - - defp get_crowding_description([_, _, _, _, _, _] = carriage_details) do - crowding_levels = - Enum.map(carriage_details, &occupancy_percentage_to_crowding_level(&1.occupancy_percentage)) - - min_crowding_level = Enum.min(crowding_levels) - - relative_crowding_levels = - for crowding_level <- crowding_levels do - if crowding_level == min_crowding_level, - do: :e, - else: :f - end - - {get_emptier_location( - {Enum.count(relative_crowding_levels, &Kernel.==(&1, :e)), relative_crowding_levels} - ), crowding_level_to_atom(min_crowding_level)} - end - - defp get_crowding_description(_), do: nil - - defp occupancy_percentage_to_crowding_level(occupancy_percentage) do - cond do - occupancy_percentage <= 12 -> 1 - occupancy_percentage <= 40 -> 2 - occupancy_percentage > 40 -> 3 - occupancy_percentage == nil -> 4 - end - end - - defp crowding_level_to_atom(crowding_level) do - case crowding_level do - 1 -> :not_crowded - 2 -> :some_crowding - 3 -> :crowded - 4 -> :unknown_crowding - end - end - - defp get_emptier_location(car_crowding_levels) do - case car_crowding_levels do - {1, [_, _, :f, :f, :f, :f]} -> :front - {1, [:f, :f, :f, :f, _, _]} -> :back - {1, [:f, :f, _, _, :f, :f]} -> :middle - {2, [_, _, _, :f, :f, :f]} -> :front - {2, [_, :f, :f, _, :f, :f]} -> :front - {2, [:f, :f, :f, _, _, _]} -> :back - {2, [:f, :f, _, :f, :f, _]} -> :back - {2, [_, _, :f, :f, _, _]} -> :front_and_back - {2, _} -> :middle - {3, [:f, _, _, _, _, :f]} -> :middle - {3, [_, _, _, _, :f, :f]} -> :front - {3, [:f, :f, _, _, _, _]} -> :back - {3, [:f, _, :f, _, :f, _]} -> :train_level - {3, [_, :f, _, :f, _, :f]} -> :train_level - {3, _} -> :front_and_back - {4, [:f, _, _, _, _, :f]} -> :middle - {4, [_, _, _, _, _, :f]} -> :front - {4, [_, _, _, :f, :f, _]} -> :front - {4, [:f, _, _, _, _, _]} -> :back - {4, [_, :f, :f, _, _, _]} -> :back - {4, [_, _, :f, :f, _, _]} -> :front_and_back - {4, _} -> :train_level - {5, [_, _, _, _, _, :f]} -> :front - {5, [:f, _, _, _, _, _]} -> :back - {5, _} -> :train_level - {6, _} -> :train_level - _ -> :train_level - end - end - - @spec new_cars?(Locations.Location.t() | nil) :: boolean() - defp new_cars?(nil) do - false - end - - defp new_cars?(%Locations.Location{ - multi_carriage_details: multi_carriage_details, - route_id: route_id - }) do - Enum.any?(multi_carriage_details, fn carriage -> - # See http://roster.transithistory.org/ for numbers of new cars - case Integer.parse(carriage.label) do - :error -> - false - - {n, _remaining} -> - route_id == "Red" and 1900 <= n and n <= 2151 - end - end) - end - defimpl Content.Message do require Logger diff --git a/lib/pa_ess/utilities.ex b/lib/pa_ess/utilities.ex index 7fa1abee..0a188933 100644 --- a/lib/pa_ess/utilities.ex +++ b/lib/pa_ess/utilities.ex @@ -716,4 +716,21 @@ defmodule PaEss.Utilities do |> Stream.chunk_every(2, 2, [""]) |> Enum.map(fn [top, bottom] -> {top, bottom, 3} end) end + + @spec prediction_new_cars?(Predictions.Prediction.t(), Signs.Realtime.t()) :: boolean() + def prediction_new_cars?(prediction, sign) do + case sign.location_engine.for_vehicle(prediction.vehicle_id) do + %Locations.Location{route_id: "Red", multi_carriage_details: carriage_details} -> + Enum.any?(carriage_details, fn carriage -> + # See http://roster.transithistory.org/ for numbers of new cars + case Integer.parse(carriage.label) do + :error -> false + {n, _remaining} -> n in 1900..2151 + end + end) + + _ -> + false + end + end end diff --git a/lib/signs/utilities/audio.ex b/lib/signs/utilities/audio.ex index 27a559f4..c27312d5 100644 --- a/lib/signs/utilities/audio.ex +++ b/lib/signs/utilities/audio.ex @@ -104,7 +104,7 @@ defmodule Signs.Utilities.Audio do Audio.TrainIsBoarding.from_message(prediction) :arriving -> - Audio.TrainIsArriving.from_message(prediction) + Audio.TrainIsArriving.from_message(prediction, nil) :approaching -> Audio.NextTrainCountdown.from_message(%{prediction | minutes: 1}) @@ -198,11 +198,12 @@ defmodule Signs.Utilities.Audio do match?(%Message.Predictions{minutes: :arriving}, message) && message.prediction.trip_id not in sign.announced_arrivals && announce_arriving?(sign, message) -> - include_crowding? = - message.crowding_data_confidence == :high && - message.prediction.trip_id not in sign.announced_approachings_with_crowding + crowding = + if message.prediction.trip_id not in sign.announced_approachings_with_crowding do + Signs.Utilities.Crowding.crowding_description(message.prediction, sign) + end - {Audio.TrainIsArriving.from_message(message, include_crowding?), + {Audio.TrainIsArriving.from_message(message, crowding), update_in(sign.announced_arrivals, &cache_value(&1, message.prediction.trip_id))} # Announce approaching if configured to @@ -210,9 +211,10 @@ defmodule Signs.Utilities.Audio do message.prediction.trip_id not in sign.announced_approachings && announce_arriving?(sign, message) && message.prediction.route_id in @heavy_rail_routes -> - include_crowding? = message.crowding_data_confidence == :high + crowding = Signs.Utilities.Crowding.crowding_description(message.prediction, sign) + new_cars? = PaEss.Utilities.prediction_new_cars?(message.prediction, sign) - {Audio.Approaching.from_message(message, include_crowding?), + {Audio.Approaching.from_message(message, crowding, new_cars?), sign |> update_in( [Access.key!(:announced_approachings)], @@ -220,7 +222,7 @@ defmodule Signs.Utilities.Audio do ) |> update_in( [Access.key!(:announced_approachings_with_crowding)], - &if(include_crowding?, do: cache_value(&1, message.prediction.trip_id), else: &1) + &if(!!crowding, do: cache_value(&1, message.prediction.trip_id), else: &1) )} # Announce stopped trains diff --git a/lib/signs/utilities/crowding.ex b/lib/signs/utilities/crowding.ex new file mode 100644 index 00000000..c41dc2a9 --- /dev/null +++ b/lib/signs/utilities/crowding.ex @@ -0,0 +1,94 @@ +defmodule Signs.Utilities.Crowding do + @spec crowding_description(Predictions.Prediction.t(), Signs.Realtime.t()) :: + {:front | :back | :middle | :front_and_back | :train_level, + :not_crowded | :some_crowding | :crowded | :unknown_crowding} + | nil + def crowding_description(_, %{source_config: {_, _}}), do: nil + + def crowding_description(%{route_id: "Orange"} = prediction, sign) do + case sign.location_engine.for_vehicle(prediction.vehicle_id) do + %Locations.Location{ + stop_id: stop_id, + status: status, + multi_carriage_details: carriage_details + } + when stop_id == prediction.stop_id and status in [:incoming_at, :in_transit_to] -> + get_crowding_description(carriage_details) + + _ -> + nil + end + end + + def crowding_description(_, _), do: nil + + defp get_crowding_description([_, _, _, _, _, _] = carriage_details) do + crowding_levels = + Enum.map(carriage_details, &occupancy_percentage_to_crowding_level(&1.occupancy_percentage)) + + min_crowding_level = Enum.min(crowding_levels) + + relative_crowding_levels = + for crowding_level <- crowding_levels do + if crowding_level == min_crowding_level, + do: :e, + else: :f + end + + {get_emptier_location( + {Enum.count(relative_crowding_levels, &Kernel.==(&1, :e)), relative_crowding_levels} + ), crowding_level_to_atom(min_crowding_level)} + end + + defp get_crowding_description(_), do: nil + + defp occupancy_percentage_to_crowding_level(occupancy_percentage) do + cond do + occupancy_percentage <= 12 -> 1 + occupancy_percentage <= 40 -> 2 + occupancy_percentage > 40 -> 3 + occupancy_percentage == nil -> 4 + end + end + + defp crowding_level_to_atom(crowding_level) do + case crowding_level do + 1 -> :not_crowded + 2 -> :some_crowding + 3 -> :crowded + 4 -> :unknown_crowding + end + end + + defp get_emptier_location(car_crowding_levels) do + case car_crowding_levels do + {1, [_, _, :f, :f, :f, :f]} -> :front + {1, [:f, :f, :f, :f, _, _]} -> :back + {1, [:f, :f, _, _, :f, :f]} -> :middle + {2, [_, _, _, :f, :f, :f]} -> :front + {2, [_, :f, :f, _, :f, :f]} -> :front + {2, [:f, :f, :f, _, _, _]} -> :back + {2, [:f, :f, _, :f, :f, _]} -> :back + {2, [_, _, :f, :f, _, _]} -> :front_and_back + {2, _} -> :middle + {3, [:f, _, _, _, _, :f]} -> :middle + {3, [_, _, _, _, :f, :f]} -> :front + {3, [:f, :f, _, _, _, _]} -> :back + {3, [:f, _, :f, _, :f, _]} -> :train_level + {3, [_, :f, _, :f, _, :f]} -> :train_level + {3, _} -> :front_and_back + {4, [:f, _, _, _, _, :f]} -> :middle + {4, [_, _, _, _, _, :f]} -> :front + {4, [_, _, _, :f, :f, _]} -> :front + {4, [:f, _, _, _, _, _]} -> :back + {4, [_, :f, :f, _, _, _]} -> :back + {4, [_, _, :f, :f, _, _]} -> :front_and_back + {4, _} -> :train_level + {5, [_, _, _, _, _, :f]} -> :front + {5, [:f, _, _, _, _, _]} -> :back + {5, _} -> :train_level + {6, _} -> :train_level + _ -> :train_level + end + end +end diff --git a/lib/signs/utilities/predictions.ex b/lib/signs/utilities/predictions.ex index 6f512f05..7849b096 100644 --- a/lib/signs/utilities/predictions.ex +++ b/lib/signs/utilities/predictions.ex @@ -51,10 +51,10 @@ defmodule Signs.Utilities.Predictions do Content.Message.StoppedTrain.from_prediction(prediction) terminal? -> - Content.Message.Predictions.terminal(prediction, station_code, zone, sign) + Content.Message.Predictions.terminal(prediction, station_code, zone) true -> - Content.Message.Predictions.non_terminal(prediction, station_code, zone, sign) + Content.Message.Predictions.non_terminal(prediction, station_code, zone) end end) |> Enum.reject(&is_nil(&1)) diff --git a/test/content/messages/predictions_test.exs b/test/content/messages/predictions_test.exs index de5faa1a..c4c13d81 100644 --- a/test/content/messages/predictions_test.exs +++ b/test/content/messages/predictions_test.exs @@ -1,17 +1,7 @@ defmodule Content.Message.PredictionsTest do use ExUnit.Case, async: true - import ExUnit.CaptureLog - import Mox - - @sign %{source_config: nil, location_engine: Engine.Locations.Mock} describe "non_terminal/3" do - setup do - stub(Engine.Locations.Mock, :for_vehicle, fn _ -> nil end) - - :ok - end - test "puts ARR on the sign when train is 0 seconds away, but not boarding" do prediction = %Predictions.Prediction{ seconds_until_arrival: 0, @@ -22,7 +12,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont ARR" end @@ -37,7 +27,7 @@ defmodule Content.Message.PredictionsTest do boarding_status: "Boarding" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont BRD" end @@ -52,7 +42,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70275" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Mattapan ARR" end @@ -67,7 +57,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70275" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Mattapan 1 min" end @@ -82,7 +72,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70275" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Mattapan 1 min" end @@ -98,7 +88,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70275" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Mattapan 20+ min" end @@ -113,7 +103,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 1 min" end @@ -128,7 +118,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 2 min" end @@ -143,7 +133,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont ARR" end @@ -158,7 +148,7 @@ defmodule Content.Message.PredictionsTest do boarding_status: "Boarding" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont BRD" end @@ -173,7 +163,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.non_terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 2 min" end @@ -188,7 +178,7 @@ defmodule Content.Message.PredictionsTest do stops_away: 2 } - msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m") assert Content.Message.to_string(msg) == [ {"Alewife (A) 5 min", 6}, @@ -206,7 +196,7 @@ defmodule Content.Message.PredictionsTest do stops_away: 2 } - msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m") assert Content.Message.to_string(msg) == [ {"Alewife (B) 5 min", 6}, @@ -224,7 +214,7 @@ defmodule Content.Message.PredictionsTest do stops_away: 2 } - msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m", @sign) + msg = Content.Message.Predictions.non_terminal(prediction, "RJFK", "m") assert Content.Message.to_string(msg) == [ {"Alewife 6 min", 6}, @@ -234,12 +224,6 @@ defmodule Content.Message.PredictionsTest do end describe "terminal/3" do - setup do - stub(Engine.Locations.Mock, :for_vehicle, fn _ -> nil end) - - :ok - end - test "puts boarding on the sign when train is supposed to be boarding according to rtr" do prediction = %Predictions.Prediction{ seconds_until_departure: 75, @@ -251,7 +235,7 @@ defmodule Content.Message.PredictionsTest do boarding_status: "Stopped at station" } - msg = Content.Message.Predictions.terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont BRD" end @@ -267,7 +251,7 @@ defmodule Content.Message.PredictionsTest do boarding_status: "Stopped at station" } - msg = Content.Message.Predictions.terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 1 min" end @@ -283,7 +267,7 @@ defmodule Content.Message.PredictionsTest do boarding_status: "Stopped at station" } - msg = Content.Message.Predictions.terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 2 min" end @@ -298,7 +282,7 @@ defmodule Content.Message.PredictionsTest do destination_stop_id: "70261" } - msg = Content.Message.Predictions.terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == "Ashmont 1 min" end @@ -313,7 +297,7 @@ defmodule Content.Message.PredictionsTest do stops_away: 0 } - msg = Content.Message.Predictions.terminal(prediction, "test", "m", @sign) + msg = Content.Message.Predictions.terminal(prediction, "test", "m") assert Content.Message.to_string(msg) == [ {"Oak Grove 2 min", 6}, diff --git a/test/signs/realtime_test.exs b/test/signs/realtime_test.exs index 238732e5..260e7e04 100644 --- a/test/signs/realtime_test.exs +++ b/test/signs/realtime_test.exs @@ -803,7 +803,7 @@ defmodule Signs.RealtimeTest do [prediction(arrival: 15, destination: :forest_hills)] end) - expect(Engine.Locations.Mock, :for_vehicle, 2, fn _ -> + expect(Engine.Locations.Mock, :for_vehicle, 1, fn _ -> location(crowding_confidence: :high) end) @@ -822,7 +822,7 @@ defmodule Signs.RealtimeTest do [prediction(arrival: 15, destination: :forest_hills)] end) - expect(Engine.Locations.Mock, :for_vehicle, 2, fn _ -> + expect(Engine.Locations.Mock, :for_vehicle, 1, fn _ -> location(crowding_confidence: :low) end) @@ -841,10 +841,6 @@ defmodule Signs.RealtimeTest do [prediction(arrival: 15, destination: :forest_hills, trip_id: "1")] end) - expect(Engine.Locations.Mock, :for_vehicle, 2, fn _ -> - location(crowding_confidence: :high) - end) - expect_messages({"Frst Hills ARR", ""}) expect_audios([{:canned, {"103", ["32103"], :audio_visual}}], [ @@ -1748,8 +1744,6 @@ defmodule Signs.RealtimeTest do [prediction(destination: :alewife, arrival: 240, stop_id: "70086")] end) - expect(Engine.Locations.Mock, :for_vehicle, fn _ -> nil end) - expect(Engine.LastTrip.Mock, :get_recent_departures, fn "1" -> %{"a" => ~U[2023-01-01 00:00:00.000Z]} end)