Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/hex/credo-1.7.5
Browse files Browse the repository at this point in the history
  • Loading branch information
bfauble authored May 16, 2024
2 parents 72f6e95 + 8f4f9d5 commit 34b8646
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 40 deletions.
6 changes: 6 additions & 0 deletions apps/parse/lib/parse/alerts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule Parse.Alerts do
the basic field set.
"""

require Logger
use Timex

alias Model.Alert
Expand Down Expand Up @@ -75,6 +76,11 @@ defmodule Parse.Alerts do
copy(cause)
end

defp cause(alert) do
Logger.error("No cause found in alert: #{inspect(alert)}")
""
end

def lifecycle("ONGOING"), do: "ONGOING"
def lifecycle("UPCOMING"), do: "UPCOMING"
def lifecycle(<<"UPCOMING", _::binary-1, "ONGOING">>), do: "ONGOING_UPCOMING"
Expand Down
101 changes: 77 additions & 24 deletions apps/state/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ config :state, :stops_on_route,
"Shuttle-LynnNorthStationExpress-0-" => true,
"Shuttle-LynnSwampscott-0-" => true,
"Shuttle-NorthStationSwampscott-0-" => true,
"Shuttle-NorthStationSwampscottLimited-0-" => true,
"Shuttle-NorthStationSwampscottLocal-0-" => true,
"Shuttle-NorthStationSwampscottExpress-0-" => true,
"CR-Newburyport-adde8a7c-" => true,
"CR-Newburyport-76fa2c91-" => true,
"CR-Newburyport-173cb7ae-" => true,
Expand Down Expand Up @@ -230,6 +233,7 @@ config :state, :stops_on_route,
"Shuttle-HaverhillReadingLocal-0-" => true,
"Shuttle-AndersonWoburnReading-0-" => true,
"Shuttle-OakGroveReading-0-" => true,
"Shuttle-NorthStationReading-0-" => true,
"CR-Haverhill-fc94d3b2-" => true,
"CR-Haverhill-9a2b8f60-" => true,
# Lowell Line shuttles
Expand All @@ -242,6 +246,8 @@ config :state, :stops_on_route,
"CR-Greenbush-BraintreeGreenbush-" => true,
"CR-Middleborough-52b80476-0_MM-0277-S_MM-0356-S_0" => true,
"CR-Middleborough-75bed2bb-1_MM-0356-S_MM-0277-S_2" => true,
"CR-Middleborough-92c25d3b-0_MM-0277-S_MM-0356-S_0" => true,
"CR-Middleborough-bb403e6b-1_MM-0356-S_MM-0277-S_2" => true,
# Franklin/Foxboro Line shuttles
"Shuttle-ForgeParkWalpole-0-" => true,
"CR-Franklin-3badde55-" => true,
Expand All @@ -258,14 +264,35 @@ config :state, :stops_on_route,
config :state, :stops_on_route,
stop_order_overrides: %{
{"CR-Franklin", 0} => [
["Norwood Central", "Windsor Gardens", "Plimptonville", "Walpole"],
[
"place-NEC-2203",
"place-DB-2265",
"place-DB-2258",
"place-DB-2249",
"place-DB-2240",
"place-DB-2230",
"place-DB-2222",
"place-DB-2205",
"place-DB-0095",
"place-FB-0109"
],
["place-FB-0148", "place-FB-0166", "place-FB-0177", "place-FB-0191"],
["Walpole", "Foxboro", "Norfolk"],
["place-FB-0191", "place-FS-0049", "place-FB-0230"]
],
{"CR-Franklin", 1} => [
["Norfolk", "Foxboro", "Walpole"],
["place-FB-0230", "place-FS-0049", "place-FB-0191"]
["place-FB-0230", "place-FS-0049", "place-FB-0191"],
[
"place-FB-0109",
"place-DB-0095",
"place-DB-2205",
"place-DB-2222",
"place-DB-2230",
"place-DB-2240",
"place-DB-2249",
"place-DB-2258",
"place-DB-2265",
"place-NEC-2203"
]
],
{"CR-Fairmount", 0} => [
["Readville", "Dedham Corp Center", "Foxboro"],
Expand Down Expand Up @@ -361,7 +388,30 @@ config :state, :stops_on_route,
[
"place-rugg",
"place-forhl",
"place-NEC-2203"
"place-NEC-2203",
"place-DB-0095"
],
[
"place-NEC-2040",
"place-NEC-1969",
"place-NEC-1919",
"place-NEC-1891",
"place-NEC-1851"
]
],
{"CR-Providence", 1} => [
[
"place-NEC-1851",
"place-NEC-1891",
"place-NEC-1919",
"place-NEC-1969",
"place-NEC-2040"
],
[
"place-DB-0095",
"place-NEC-2203",
"place-forhl",
"place-rugg"
]
],
{"CR-Greenbush", 0} => [
Expand Down Expand Up @@ -426,22 +476,26 @@ config :state, :stops_on_route,
config :state, :stops_on_route,
not_on_route: %{
{"CR-Franklin", 0} => [
"place-DB-2265",
"place-DB-2258",
"place-DB-2249",
"place-DB-2240",
"place-DB-2230",
"place-DB-2222",
"place-DB-2205"
"place-NEC-2173",
"place-NEC-2139",
"place-NEC-2108",
"place-NEC-2040",
"place-NEC-1919",
"place-NEC-1969",
"place-NEC-1851",
"place-NEC-1768",
"place-NEC-1659"
],
{"CR-Franklin", 1} => [
"place-DB-2265",
"place-DB-2258",
"place-DB-2249",
"place-DB-2240",
"place-DB-2230",
"place-DB-2222",
"place-DB-2205"
"place-NEC-2173",
"place-NEC-2139",
"place-NEC-2108",
"place-NEC-2040",
"place-NEC-1919",
"place-NEC-1969",
"place-NEC-1851",
"place-NEC-1768",
"place-NEC-1659"
],
{"CR-Providence", 0} => [
"place-DB-2265",
Expand All @@ -450,8 +504,7 @@ config :state, :stops_on_route,
"place-DB-2240",
"place-DB-2230",
"place-DB-2222",
"place-DB-2205",
"place-DB-0095"
"place-DB-2205"
],
{"CR-Providence", 1} => [
"place-DB-2265",
Expand All @@ -460,8 +513,7 @@ config :state, :stops_on_route,
"place-DB-2240",
"place-DB-2230",
"place-DB-2222",
"place-DB-2205",
"place-DB-0095"
"place-DB-2205"
],
{"CR-Fairmount", 0} => [
"place-FB-0166",
Expand Down Expand Up @@ -717,7 +769,8 @@ config :state, :stops_on_route,
"6551",
"190",
"9070025",
"9070080"
"9070080",
"151"
]
}

Expand Down
32 changes: 20 additions & 12 deletions apps/state/test/state/stops_on_route_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ defmodule State.StopsOnRouteTest do
test "shows Plimptonville after Windsor Gardens even when they don't share a trip" do
State.Stop.new_state([
%Model.Stop{id: "place-sstat"},
%Model.Stop{id: "Windsor Gardens"},
%Model.Stop{id: "Plimptonville"},
%Model.Stop{id: "Walpole"},
%Model.Stop{id: "Franklin"}
%Model.Stop{id: "place-FB-0166"},
%Model.Stop{id: "place-FB-0177"},
%Model.Stop{id: "place-FB-0191"},
%Model.Stop{id: "place-FB-0275"}
])

State.Route.new_state([%Model.Route{id: "CR-Franklin"}])
Expand All @@ -310,28 +310,36 @@ defmodule State.StopsOnRouteTest do

State.Schedule.new_state([
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "place-sstat", stop_sequence: 1},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "Plimptonville", stop_sequence: 2},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "Franklin", stop_sequence: 3},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "place-FB-0177", stop_sequence: 2},
%Model.Schedule{trip_id: "via-plimptonville", stop_id: "place-FB-0275", stop_sequence: 3},
# Windsor Gardens trip has more stops because this bug only shows up when the merge
# has windor gardens on the left and plimptonville on the right.
# They're sorted by length before merging, so this forces them to be in the order to make the bug appear.
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "place-sstat", stop_sequence: 1},
%Model.Schedule{
trip_id: "via-windsor-gardens",
stop_id: "Windsor Gardens",
stop_id: "place-FB-0166",
stop_sequence: 2
},
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "Walpole", stop_sequence: 3},
%Model.Schedule{trip_id: "via-windsor-gardens", stop_id: "Franklin", stop_sequence: 4}
%Model.Schedule{
trip_id: "via-windsor-gardens",
stop_id: "place-FB-0191",
stop_sequence: 3
},
%Model.Schedule{
trip_id: "via-windsor-gardens",
stop_id: "place-FB-0275",
stop_sequence: 4
}
])

update!()

stop_ids = by_route_id("CR-Franklin")

assert Enum.filter(stop_ids, &(&1 in ["Windsor Gardens", "Plimptonville"])) == [
"Windsor Gardens",
"Plimptonville"
assert Enum.filter(stop_ids, &(&1 in ["place-FB-0166", "place-FB-0177"])) == [
"place-FB-0166",
"place-FB-0177"
]
end

Expand Down
21 changes: 17 additions & 4 deletions apps/state_mediator/test/state_mediator/integration/gtfs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,30 @@ defmodule StateMediator.Integration.GtfsTest do
assert [%{name: "Braintree - Alewife"}, %{name: "Ashmont - Alewife"}] = shapes_1
end

test "Providence/Stoughton has 2 non-ignored shapes each direction" do
test "Providence/Stoughton has at least 2 non-ignored shapes in direction 0 and 2 in direction 1" do
[shapes_0, shapes_1] = shapes_in_both_directions("CR-Providence")

assert [
shape_0,
%{id: "9890004"},
%{id: "SouthStationToStoughtonViaFairmount"}
# South Station - Wickford Junction via Back Bay
shape_0
| remaining_shapes
] = shapes_0

assert shape_0.name =~ "South Station - Wickford Junction"

Enum.each(remaining_shapes, fn shape ->
assert shape.id in [
# South Station - Stoughton via Back Bay
"9890004",
# South Station - Stoughton via Fairmount
"SouthStationToStoughtonViaFairmount",
# South Station - Wickford Junction
"9890009"
]
end)

assert Enum.count(remaining_shapes) >= 1

assert [%{name: "Wickford Junction - South Station"}, %{id: "9890003"}] = shapes_1
end

Expand Down

0 comments on commit 34b8646

Please sign in to comment.