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
4 changes: 2 additions & 2 deletions lib/dotcom_web/controllers/schedule/defaults.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ defmodule DotcomWeb.Schedule.Defaults do
def default_direction_id(%Conn{assigns: %{route: %Route{id: route_id}}} = conn) do
direction_id = default_direction_id_for_hour(conn.assigns.date_time.hour)

# SL1 and SL2 are outbound in the morning, inbound otherwise
if route_id in ["741", "742"] do
# SL1, SL2, and Harbor Loop Ferry are outbound in the morning, inbound otherwise
if route_id in ["741", "742", "Boat-F10"] do
invert_direction_id(direction_id)
else
direction_id
Expand Down
44 changes: 44 additions & 0 deletions lib/dotcom_web/views/schedule_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,50 @@ defmodule DotcomWeb.ScheduleView do
end
end

def timetable_note(%{route: %Route{id: "Boat-F10"}, direction_id: 0, date: date}) do
content_tag :div, class: "m-timetable__note" do
[
content_tag(:p, [
content_tag(:strong, ~t"Note:"),
gettext(
" Service continues later in the day in the opposite direction. %{link}",
%{
link:
link(~t"View evening timetable",
to:
"/schedules/Boat-F10/timetable?schedule_direction[direction_id]=1&date=#{date}#direction-filter"
)
|> safe_to_string()
}
)
|> raw()
])
]
end
end

def timetable_note(%{route: %Route{id: "Boat-F10"}, direction_id: 1, date: date}) do
content_tag :div, class: "m-timetable__note" do
[
content_tag(:p, [
content_tag(:strong, ~t"Note:"),
gettext(
" Service is available earlier in the day in the opposite direction. %{link}",
%{
link:
link(~t"View morning timetable",
to:
"/schedules/Boat-F10/timetable?schedule_direction[direction_id]=0&date=#{date}#direction-filter"
)
|> safe_to_string()
}
)
|> raw()
])
]
end
end

def timetable_note(_), do: nil

def json_safe_route(route) do
Expand Down
13 changes: 13 additions & 0 deletions lib/routes/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ defmodule Routes.Repo do
{:error, _} -> nil
end
|> update_direction_destinations()
|> update_direction_names()
end

# Ferries F1 and F2H are functionally the same route for riders, but are treated separately
Expand All @@ -70,6 +71,18 @@ defmodule Routes.Repo do

defp update_direction_destinations(route), do: route

defp update_direction_names(%Route{id: "Boat-F10"} = route) do
%Route{
route
| direction_names:
route.direction_names
|> Map.put(0, "Counterclockwise (Morning)")
|> Map.put(1, "Clockwise (Evening)")
}
end

defp update_direction_names(route), do: route

@decorate cacheable(cache: @cache, on_error: :nothing, opts: [ttl: @ttl])

defp cached_get(id, opts) do
Expand Down
10 changes: 10 additions & 0 deletions test/routes/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ defmodule Routes.RepoTest do
route = get("Boat-F2H")
assert route.direction_destinations[1] == "Long Wharf or Rowes Wharf"
end

test "updates the direction names for 'Boat-F10'" do
expect(MBTA.Api.Mock, :get_json, fn "/routes/Boat-F10", _ ->
%JsonApi{data: [build(:route_item, id: "Boat-F10")]}
end)

route = get("Boat-F10")
assert route.direction_names[0] == "Counterclockwise (Morning)"
assert route.direction_names[1] == "Clockwise (Evening)"
end
end

test "frequent bus routes are tagged" do
Expand Down
Loading