From 6da306ae458168cbca4d2822f602b32fffa36f9f Mon Sep 17 00:00:00 2001 From: Paul Swartz Date: Mon, 9 Dec 2024 13:20:35 -0500 Subject: [PATCH] fix(ClosedStops): only treat a stop as closed if you can't board or exit If you can do one of them, then it's not fully closed. --- lib/concentrate/filter/alert/closed_stops.ex | 5 ++++- test/concentrate/filter/alert/closed_stops_test.exs | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/concentrate/filter/alert/closed_stops.ex b/lib/concentrate/filter/alert/closed_stops.ex index fb90442d..48b18dc0 100644 --- a/lib/concentrate/filter/alert/closed_stops.ex +++ b/lib/concentrate/filter/alert/closed_stops.ex @@ -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 diff --git a/test/concentrate/filter/alert/closed_stops_test.exs b/test/concentrate/filter/alert/closed_stops_test.exs index 89276cd5..20eeafd3 100644 --- a/test/concentrate/filter/alert/closed_stops_test.exs +++ b/test/concentrate/filter/alert/closed_stops_test.exs @@ -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"]) ] ) @@ -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