Skip to content

Commit

Permalink
fix(ClosedStops): only treat a stop as closed if you can't board or exit
Browse files Browse the repository at this point in the history
If you can do one of them, then it's not fully closed.
  • Loading branch information
paulswartz committed Dec 10, 2024
1 parent 010817a commit 6da306a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/concentrate/filter/alert/closed_stops.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ defmodule Concentrate.Filter.Alert.ClosedStops do
defp closed_stop_entities(alert) do
cond do
Alert.effect(alert) == :NO_SERVICE ->
for entity <- Alert.informed_entity(alert), not is_nil(InformedEntity.stop_id(entity)) do
for entity <- Alert.informed_entity(alert),
not is_nil(InformedEntity.stop_id(entity)),
"BOARD" in InformedEntity.activities(entity),
"EXIT" in InformedEntity.activities(entity) do
entity
end

Expand Down
4 changes: 3 additions & 1 deletion test/concentrate/filter/alert/closed_stops_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ defmodule Concentrate.Filter.Alert.ClosedStopsTest do
informed_entity: [
stop_only = InformedEntity.new(stop_id: "stop"),
stop_route = InformedEntity.new(stop_id: "other", route_id: "route"),
stop_route_2 = InformedEntity.new(stop_id: "other", route_id: "route 2")
stop_route_2 = InformedEntity.new(stop_id: "other", route_id: "route 2"),
InformedEntity.new(stop_id: "partially_closed", activities: ["RIDE", "EXIT"])
]
)

Expand All @@ -35,6 +36,7 @@ defmodule Concentrate.Filter.Alert.ClosedStopsTest do
assert stop_closed_for("other", "route 2", 20) == [stop_route_2]
assert stop_closed_for("other", "other_route", 20) == []
assert stop_closed_for("stop", "route", 12) == []
assert stop_closed_for("partially_closed", "route", 5) == []
assert stop_closed_for("unknown", "route", 8) == []
end

Expand Down

0 comments on commit 6da306a

Please sign in to comment.