Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions lib/screens/alerts/informed_entity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,16 @@ defmodule Screens.Alerts.InformedEntity do
end)
|> Enum.filter(fn ie -> not is_nil(ie.stop) end)
end

@spec boarding_platforms_from_entities([t()]) :: [Stop.t()]
def boarding_platforms_from_entities(informed_parent_stations) do
informed_parent_stations
|> Enum.flat_map(
&case &1.stop.child_stops do
nil -> []
child_stops -> child_stops
end
)
|> Stop.filter_subway_platforms()
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ defmodule Screens.V2.CandidateGenerator.Widgets.ReconstructedAlert do
# Given informed entities representing an alert at a single station,
# finds the corresponding platform names for those child stops included.
with [informed_parent_station] <- Alert.informed_parent_stations(alert),
[_ | _] = child_platforms <- informed_parent_station.stop.child_stops,
[_ | _] = child_platforms <-

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test that we can write for this change that covers filtering to subway/light rail platforms here before determining the closure type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but I wanted to get this fix in quickly since this alert is active. Could add a quick unit test for this case later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added modifications to the tests here: #3103

InformedEntity.boarding_platforms_from_entities([informed_parent_station]),
:partial_closure <- Alert.station_closure_type(alert, child_platforms) do
platform_ids =
child_platforms |> Stop.filter_subway_platforms() |> Enum.map(& &1.id) |> MapSet.new()
child_platforms |> Enum.map(& &1.id) |> MapSet.new()

informed_entities
|> Enum.filter(&(&1.stop.id in platform_ids))
Expand Down
10 changes: 2 additions & 8 deletions lib/screens/v2/widget_instance/subway_status/serialize.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ defmodule Screens.V2.WidgetInstance.SubwayStatus.Serialize do
"""

alias Screens.Alerts.Alert
alias Screens.Alerts.InformedEntity
alias Screens.Routes.Route
alias Screens.Stops.Stop
alias Screens.V2.WidgetInstance.SubwayStatus
alias Screens.V2.WidgetInstance.SubwayStatus.Serialize.GreenLine
alias Screens.V2.WidgetInstance.SubwayStatus.Serialize.RedLine
Expand Down Expand Up @@ -251,13 +251,7 @@ defmodule Screens.V2.WidgetInstance.SubwayStatus.Serialize do
child_platforms_at_informed_stations =
alert
|> Alert.informed_parent_stations()
|> Enum.flat_map(
&case &1.stop.child_stops do
nil -> []
child_stops -> child_stops
end
)
|> Stop.filter_subway_platforms()
|> InformedEntity.boarding_platforms_from_entities()

case Alert.station_closure_type(alert, child_platforms_at_informed_stations) do
# Logic for partial_station_closure will remove any alerts that apply to more than
Expand Down
Loading