Skip to content

Commit

Permalink
Remove hardcoded stuff related to Wollaston closure (#141)
Browse files Browse the repository at this point in the history
* Remove greyed-out Wollaston stop from selectors

* Remove hardcoded Wollaston alert

* Update Backstop images to omit Wollaston for the moment
  • Loading branch information
phildarnowsky authored Aug 15, 2019
1 parent 10f3bb1 commit e822806
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 266 deletions.
12 changes: 0 additions & 12 deletions apps/site/lib/site_web/controllers/schedule/all_stops.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule SiteWeb.ScheduleController.AllStops do
@moduledoc "Fetch all the stops on a route and assign them as @all_stops"
@behaviour Plug
import Plug.Conn, only: [assign: 3]
import SiteWeb.ScheduleController.ClosedStops, only: [add_wollaston: 4]

@impl true
def init([]), do: []
Expand Down Expand Up @@ -32,17 +31,6 @@ defmodule SiteWeb.ScheduleController.AllStops do

route_id
|> repo_fn.(direction_id, date: date)
|> maybe_add_wollaston(route_id, direction_id)
end

@spec maybe_add_wollaston(Stops.Repo.stops_response(), Routes.Route.id_t(), 0 | 1) ::
Stops.Repo.stops_response()
defp maybe_add_wollaston(stops, "Red", direction) when is_list(stops) do
add_wollaston(stops, direction, & &1, fn _elem, stop -> stop end)
end

defp maybe_add_wollaston(stops, _, _) do
stops
end

defp assign_all_stops(conn, stops) when is_list(stops) do
Expand Down
46 changes: 0 additions & 46 deletions apps/site/lib/site_web/controllers/schedule/closed_stops.ex

This file was deleted.

18 changes: 0 additions & 18 deletions apps/site/lib/site_web/controllers/schedule/line.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defmodule SiteWeb.ScheduleController.Line do
@behaviour Plug
import Plug.Conn, only: [assign: 3]
import SiteWeb.ScheduleController.ClosedStops, only: [add_wollaston: 4]

alias Plug.Conn
alias RoutePatterns.Repo, as: RoutePatternRepo
Expand Down Expand Up @@ -453,27 +452,10 @@ defmodule SiteWeb.ScheduleController.Line do
branch_stops
|> EnumHelpers.with_first_last()
|> Enum.reduce(all_stops, &build_branched_stop(&1, &2, {current_branch, branch_names}))
|> add_wollaston_on_red_line(current_branch)

{stop_list, branch_names}
end

defp extract_fn({_bubbles, stop}), do: stop

defp build_fn({bubbles, _stop}, new_stop), do: {bubbles, new_stop}

@spec add_wollaston_on_red_line([RouteStops.t()], Route.branch_name()) :: [RouteStops.t()]
defp add_wollaston_on_red_line(
[{_, %RouteStop{route: %Route{id: "Red"}}} | _tail] = stop_list,
nil
) do
add_wollaston(stop_list, 0, &extract_fn/1, &build_fn/2)
end

defp add_wollaston_on_red_line(stop_list, _current_branch) do
stop_list
end

@doc """
Builds stop bubble information for a stop, and adds the stop to the list of all stops
as a tuple of {stop_bubbles, %RouteStop{}}.
Expand Down
26 changes: 1 addition & 25 deletions apps/site/lib/site_web/controllers/schedule/trip_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ defmodule SiteWeb.ScheduleController.TripInfo do
import Plug.Conn, only: [assign: 3, halt: 1]
import Phoenix.Controller, only: [redirect: 2]
import UrlHelpers, only: [update_url: 2]
import SiteWeb.ScheduleController.ClosedStops, only: [add_wollaston: 4]

require Routes.Route
alias Routes.Route
Expand Down Expand Up @@ -88,33 +87,10 @@ defmodule SiteWeb.ScheduleController.TripInfo do
possibly_remove_trip_query(conn)

info ->
assign_trip_info(conn, info)
assign(conn, :trip_info, info)
end
end

defp assign_trip_info(%{assigns: %{route: %{id: "Red"}}} = conn, %{times: times} = info) do
assign(conn, :trip_info, %{
info
| times:
add_wollaston(
times,
direction_id(times),
&PredictedSchedule.stop/1,
&PredictedSchedule.put_stop/2
)
})
end

defp assign_trip_info(conn, info) do
assign(conn, :trip_info, info)
end

defp direction_id(times) do
times
|> List.first()
|> PredictedSchedule.direction_id()
end

defp possibly_remove_trip_query(%{query_params: %{"trip" => _}} = conn) do
url = update_url(conn, trip: nil)

Expand Down
1 change: 0 additions & 1 deletion apps/site/lib/site_web/templates/schedule/_alerts.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<div class="col-xs-12 col-lg-8 col-lg-offset-1">
<h2 class="h2">Alerts</h2>
<%= SiteWeb.AlertView.group(alerts: @alerts, route: @route, date_time: @date_time, show_empty?: true, timeframe: @alerts_timeframe) %>
<%= render "_route_disclaimer.html", route: @route, date_time: @date_time %>
</div>
</div>
</div>
1 change: 0 additions & 1 deletion apps/site/lib/site_web/templates/schedule/_line.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<div class="row">
<div class="col-md-12">
<%= SiteWeb.AlertView.group(alerts: @alerts, route: @route, date_time: @date_time, priority_filter: :high) %>
<%= render "_route_disclaimer.html", route: @route, date_time: @date_time %>
</div>
<div class="col-xs-12 col-md-7">
<div id="react-schedule-note-root">
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@
<% end %>
</div>
</div>
<%= render "_route_disclaimer.html", route: @route, date_time: @date_time %>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 0 additions & 17 deletions apps/site/test/site_web/controllers/schedule/all_stops_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ defmodule SiteWeb.ScheduleController.AllStopsTest do
assert conn.assigns.all_stops == stops_by_route("Blue", 1, date: Util.service_date())
end

test "gets all Red line stops and adds wollaston", %{conn: conn} do
conn =
conn
|> assign(:date, Util.service_date())
|> assign(:date_in_rating?, true)
|> assign(:direction_id, 1)
|> assign(:route, %Routes.Route{id: "Red"})
|> AllStops.call(repo_fn: &stops_by_route/3)

all_stops = conn.assigns[:all_stops]
refute conn.assigns.all_stops == stops_by_route("Red", 1, date: Util.service_date())

assert length(all_stops) > 0
assert length(all_stops) == length(Enum.uniq_by(all_stops, & &1.id))
assert Enum.find(all_stops, fn s -> s.id == "place-wstn" end)
end

test "still fetches stops if provided date is outside of the rating", %{conn: conn} do
date =
Schedules.Repo.end_of_rating()
Expand Down
61 changes: 0 additions & 61 deletions apps/site/test/site_web/controllers/schedule/closed_stops_test.exs

This file was deleted.

58 changes: 0 additions & 58 deletions apps/site/test/site_web/controllers/schedule/trip_info_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -678,63 +678,5 @@ defmodule SiteWeb.ScheduleController.TripInfoTest do

assert stops == ["id2", "id1"]
end

test "Adds Wollaston in correct place for Red line routes with direction_id=0", %{conn: conn} do
init = init(trip_fn: &trip_fn/2, vehicle_fn: &vehicle_fn/1, prediction_fn: &prediction_fn/1)
route = %{id: "Red"}

times = [
%{times: %{direction_id: 0, route: %{id: "Red"}, stop: %{id: "place-nqncy"}}},
%{times: %{direction_id: 0, route: %{id: "Red"}, stop: %{id: "place-qnctr"}}}
]

trip_info = %{route: route, times: times}

conn =
%{conn | query_params: %{"trip" => "red-trip-0"}}
|> assign(:route, route)
|> assign(:trip_info, trip_info)
|> assign(:vehicle_locations, %{})
|> call(init)

stops = Enum.map(conn.assigns.trip_info.times, & &1.schedule.stop.id)

assert stops == ["place-nqncy", "place-wstn", "place-qnctr"]
end

test "Adds Wollaston in correct place for Red line routes with direction_id=1", %{conn: conn} do
init = init(trip_fn: &trip_fn/2, vehicle_fn: &vehicle_fn/1, prediction_fn: &prediction_fn/1)
route = %{id: "Red"}

times = [
%{
times: %{
direction_id: 1,
route: %{id: "Red"},
stop: %{id: "place-qnctr", name: "Quincy Center"}
}
},
%{
times: %{
direction_id: 1,
route: %{id: "Red"},
stop: %{id: "place-nqncy", name: "North Quincy"}
}
}
]

trip_info = %{route: route, times: times}

conn =
%{conn | query_params: %{"trip" => "red-trip-1"}}
|> assign(:route, route)
|> assign(:trip_info, trip_info)
|> assign(:vehicle_locations, %{})
|> call(init)

stops = Enum.map(conn.assigns.trip_info.times, & &1.schedule.stop.id)

assert stops == ["place-qnctr", "place-wstn", "place-nqncy"]
end
end
end

0 comments on commit e822806

Please sign in to comment.