From b26f9904d6201241130af606fe958fa26e9fd03f Mon Sep 17 00:00:00 2001 From: Brett Heath-Wlaz Date: Mon, 28 Oct 2024 08:51:40 -0400 Subject: [PATCH] don't modify predictions when both lines ARR (#835) --- lib/signs/utilities/predictions.ex | 39 +------------------- lib/signs/utilities/source_config.ex | 15 ++------ priv/signs.json | 14 +++----- test/signs/realtime_test.exs | 40 ++------------------- test/signs/utilities/source_config_test.exs | 18 ++++------ 5 files changed, 17 insertions(+), 109 deletions(-) diff --git a/lib/signs/utilities/predictions.ex b/lib/signs/utilities/predictions.ex index 99ff56f7..6f512f05 100644 --- a/lib/signs/utilities/predictions.ex +++ b/lib/signs/utilities/predictions.ex @@ -27,7 +27,7 @@ defmodule Signs.Utilities.Predictions do ) :: Signs.Realtime.sign_messages() | nil def prediction_messages( predictions, - %{sources: sources, terminal?: terminal?}, + %{terminal?: terminal?}, %{pa_ess_loc: station_code, text_zone: zone} = sign ) do predictions @@ -69,16 +69,6 @@ defmodule Signs.Utilities.Predictions do [msg] -> {msg, Content.Message.Empty.new()} - [ - %Content.Message.Predictions{minutes: :arriving} = p1, - %Content.Message.Predictions{minutes: :arriving} = p2 - ] -> - if allowed_multi_berth_platform?(sources, p1, p2) do - {p1, p2} - else - {p1, %{p2 | minutes: 1}} - end - [msg1, msg2] -> {msg1, msg2} end @@ -168,33 +158,6 @@ defmodule Signs.Utilities.Predictions do boarding_status != "Stopped at station" && !approximate_arrival? && !approximate_departure? end - defp allowed_multi_berth_platform?(source_list, p1, p2) do - allowed_multi_berth_platform?( - SourceConfig.get_source_by_stop_and_direction( - source_list, - p1.stop_id, - p1.direction_id - ), - SourceConfig.get_source_by_stop_and_direction( - source_list, - p2.stop_id, - p2.direction_id - ) - ) - end - - defp allowed_multi_berth_platform?( - %SourceConfig{multi_berth?: true} = s1, - %SourceConfig{multi_berth?: true} = s2 - ) - when s1 != s2 do - true - end - - defp allowed_multi_berth_platform?(_, _) do - false - end - # This is a temporary fix for a situation where spotty train sheet data can # 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 diff --git a/lib/signs/utilities/source_config.ex b/lib/signs/utilities/source_config.ex index d565f221..dd19e352 100644 --- a/lib/signs/utilities/source_config.ex +++ b/lib/signs/utilities/source_config.ex @@ -96,8 +96,7 @@ defmodule Signs.Utilities.SourceConfig do :announce_arriving?, :announce_boarding? ] - defstruct @enforce_keys ++ - [:headway_stop_id, multi_berth?: false] + defstruct @enforce_keys ++ [:headway_stop_id] @type source :: %__MODULE__{ stop_id: String.t(), @@ -105,8 +104,7 @@ defmodule Signs.Utilities.SourceConfig do direction_id: 0 | 1, routes: [String.t()] | nil, announce_arriving?: boolean(), - announce_boarding?: boolean(), - multi_berth?: boolean() + announce_boarding?: boolean() } @type config :: %{ @@ -145,19 +143,12 @@ defmodule Signs.Utilities.SourceConfig do "announce_boarding" => announce_boarding? } = source ) do - multi_berth? = - case source["multi_berth"] do - true -> true - _ -> false - end - %__MODULE__{ stop_id: stop_id, direction_id: direction_id, routes: source["routes"], announce_arriving?: announce_arriving?, - announce_boarding?: announce_boarding?, - multi_berth?: multi_berth? + announce_boarding?: announce_boarding? } end diff --git a/priv/signs.json b/priv/signs.json index b84c05fa..b316069c 100644 --- a/priv/signs.json +++ b/priv/signs.json @@ -7111,8 +7111,7 @@ "Green-D" ], "announce_arriving": false, - "announce_boarding": true, - "multi_berth": true + "announce_boarding": true }, { "stop_id": "70199", @@ -7121,8 +7120,7 @@ "Green-E" ], "announce_arriving": false, - "announce_boarding": true, - "multi_berth": true + "announce_boarding": true } ] } @@ -7149,8 +7147,7 @@ "Green-B" ], "announce_arriving": false, - "announce_boarding": true, - "multi_berth": true + "announce_boarding": true }, { "stop_id": "70197", @@ -7159,8 +7156,7 @@ "Green-C" ], "announce_arriving": false, - "announce_boarding": true, - "multi_berth": true + "announce_boarding": true } ] } @@ -9748,4 +9744,4 @@ ], "max_minutes": 75 } -] +] \ No newline at end of file diff --git a/test/signs/realtime_test.exs b/test/signs/realtime_test.exs index 883e79ea..238732e5 100644 --- a/test/signs/realtime_test.exs +++ b/test/signs/realtime_test.exs @@ -540,7 +540,7 @@ defmodule Signs.RealtimeTest do Signs.Realtime.handle_info(:run_loop, @sign) end - test "does not allow ARR on second line if platform does not have multiple berths" do + test "allows ARR on second line" do expect(Engine.Predictions.Mock, :for_stop, fn _, _ -> [ prediction(destination: :cleveland_circle, arrival: 15, stop_id: "1"), @@ -548,7 +548,7 @@ defmodule Signs.RealtimeTest do ] end) - expect_messages({"Clvlnd Cir ARR", "Riverside 1 min"}) + expect_messages({"Clvlnd Cir ARR", "Riverside ARR"}) expect_audios([{:canned, {"103", ["90007"], :audio_visual}}], [ {"Attention passengers: The next C train to Cleveland Circle is now arriving.", @@ -558,42 +558,6 @@ defmodule Signs.RealtimeTest do Signs.Realtime.handle_info(:run_loop, @sign) end - test "allows ARR on second line if platform does have multiple berths" do - expect(Engine.Predictions.Mock, :for_stop, fn _, _ -> - [prediction(destination: :cleveland_circle, arrival: 15, stop_id: "1", trip_id: "1")] - end) - - expect(Engine.Predictions.Mock, :for_stop, fn _, _ -> - [prediction(destination: :riverside, arrival: 16, stop_id: "2", trip_id: "2")] - end) - - expect_messages({"Clvlnd Cir ARR", "Riverside ARR"}) - - expect_audios( - [ - {:canned, {"103", ["90007"], :audio_visual}}, - {:canned, {"103", ["90008"], :audio_visual}} - ], - [ - {"Attention passengers: The next C train to Cleveland Circle is now arriving.", - [{"C train to Clvlnd Cir", "now arriving", 6}]}, - {"Attention passengers: The next D train to Riverside is now arriving.", - [{"D train to Riverside", "now arriving", 6}]} - ] - ) - - Signs.Realtime.handle_info(:run_loop, %{ - @sign - | source_config: %{ - @sign.source_config - | sources: [ - %{@src | stop_id: "1", multi_berth?: true}, - %{@src | stop_id: "2", multi_berth?: true} - ] - } - }) - end - test "doesn't sort 0 stops away to first for terminals when another departure is sooner" do expect(Engine.Predictions.Mock, :for_stop, fn _, _ -> [ diff --git a/test/signs/utilities/source_config_test.exs b/test/signs/utilities/source_config_test.exs index 5be5889a..0d80665c 100644 --- a/test/signs/utilities/source_config_test.exs +++ b/test/signs/utilities/source_config_test.exs @@ -21,8 +21,7 @@ defmodule Signs.Utilities.SourceConfigTest do "routes": ["Bar"], "direction_id": 1, "announce_arriving": true, - "announce_boarding": false, - "multi_berth": true + "announce_boarding": false } ] } @@ -80,8 +79,7 @@ defmodule Signs.Utilities.SourceConfigTest do "routes": ["Bar"], "direction_id": 1, "announce_arriving": true, - "announce_boarding": false, - "multi_berth": true + "announce_boarding": false } ] } @@ -100,16 +98,14 @@ defmodule Signs.Utilities.SourceConfigTest do routes: ["Foo"], direction_id: 0, announce_arriving?: false, - announce_boarding?: false, - multi_berth?: false + announce_boarding?: false }, %SourceConfig{ stop_id: "234", routes: ["Bar"], direction_id: 1, announce_arriving?: true, - announce_boarding?: false, - multi_berth?: true + announce_boarding?: false } ] } @@ -162,16 +158,14 @@ defmodule Signs.Utilities.SourceConfigTest do routes: ["Foo"], direction_id: 0, announce_arriving?: false, - announce_boarding?: false, - multi_berth?: false + announce_boarding?: false }, %SourceConfig{ stop_id: "234", routes: ["Bar"], direction_id: 1, announce_arriving?: true, - announce_boarding?: false, - multi_berth?: true + announce_boarding?: false } ] }