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
6 changes: 5 additions & 1 deletion lib/timetable_loader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ defmodule Dotcom.TimetableLoader do
@metadata %{
"Boat-F6" => %{
effective_dates: {~D[2026-04-27], ~D[2026-06-13]},
special_dates: %{~D[2026-05-25] => "Boat-F8"},
weekend: "Boat-F8"
},
"Boat-F7" => %{
effective_dates: {~D[2026-04-27], ~D[2026-06-13]},
special_dates: %{~D[2026-05-25] => "Boat-F8"},
weekend: "Boat-F8"
},
"Boat-F8" => %{
Expand All @@ -42,7 +44,9 @@ defmodule Dotcom.TimetableLoader do
"""
@spec from_csv(Routes.Route.id_t(), 0 | 1, Date.t()) :: {:ok, list()} | {:error, term()}
def from_csv(route_id, direction_id, date) when route_id in @available_route_ids do
route_id = maybe_use_weekend_route(route_id, date)
route_id =
get_in(@metadata, [route_id, :special_dates, date]) ||
maybe_use_weekend_route(route_id, date)

if in_timetable_date_range?(route_id, date) do
case @loader_module.get_csv("#{route_id}-#{direction_id}.csv") do
Expand Down
4 changes: 2 additions & 2 deletions priv/timetables/Boat-F8-1.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Stop,0845,1030,1215,1500,1645,1830,2015
Boat-Winthrop,8:45 AM,10:30 AM,12:15 PM,3:00 PM,4:45 PM,6:30 PM,8:15 PM
Boat-Quincy,9:10 AM,10:55 AM,12:40 PM,3:35 PM,5:00 PM,6:55 PM,8:40 PM
Boat-Quincy,9:10 AM,10:55 AM,12:40 PM,3:25 PM,5:10 PM,6:55 PM,8:40 PM
Boat-Fan,9:35 AM,11:20 AM,1:05 PM,3:50 PM,5:35 PM,7:20 PM,9:05 PM
Boat-Aquarium,9:45 AM,11:30 AM,1:15 PM,4:00 PM,5:45 PM,7:30 PM,9:15 PM
Boat-Logan,9:55 AM,11:40 AM,1:25 PM,4:10 PM,5:55 PM,7:40 PM,9:25 PM
Boat-Fan,10:05 AM,11:50 AM,,4:20 PM,6:05 PM,7:50 PM,9:35 PM
Boat-Winthrop,10:30 AM,12:15 PM,,4:45 PM,6:30 PM,8:15 PM,10:00 PM
Boat-Quincy,10:55 AM,12:40 PM,,5:00 PM,6:55 PM,8:40 PM,10:25 PM
Boat-Quincy,10:55 AM,12:40 PM,,5:10 PM,6:55 PM,8:40 PM,10:25 PM
13 changes: 13 additions & 0 deletions test/timetable_loader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,18 @@ defmodule Dotcom.TimetableLoaderTest do
invalid_date = ~D[2025-12-25]
assert from_csv(valid_route_id, 1, invalid_date) == {:ok, []}
end

test "special case: specific overrides for F6/F7 return F8 table" do
f6_or_f7 = Faker.Util.pick(~w(Boat-F6 Boat-F7))

memorial_day = ~D[2026-05-25]

expect(Dotcom.TimetableLoader.Mock, :get_csv, fn filename ->
assert filename =~ "Boat-F8"
[]
end)

assert {:ok, _} = from_csv(f6_or_f7, 1, memorial_day)
end
end
end
Loading