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
2 changes: 2 additions & 0 deletions lib/dotcom/schedule_finder/upcoming_departures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule Dotcom.ScheduleFinder.UpcomingDepartures do
defstruct [
:arrival_status,
:headsign,
:route,
:trip_details,
:trip_id
]
Expand Down Expand Up @@ -137,6 +138,7 @@ defmodule Dotcom.ScheduleFinder.UpcomingDepartures do
now: now
}),
headsign: trip.headsign,
route: PredictedSchedule.route(predicted_schedule),
trip_details: trip_details,
trip_id: trip.id
}
Expand Down
10 changes: 9 additions & 1 deletion lib/dotcom_web/components/prototype.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule DotcomWeb.Components.Prototype do
def route_stop_picker(%{selected_route: route, selected_direction_id: direction} = assigns) do
assigns =
assigns
|> assign(:all_routes, @routes_repo.all())
|> assign(:all_routes, all_routes_with_green_line())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, thanks for this!

|> assign_new(:stops, fn ->
if not is_nil(route) and not is_nil(direction) do
@stops_repo.by_route(route.id, direction)
Expand Down Expand Up @@ -76,4 +76,12 @@ defmodule DotcomWeb.Components.Prototype do
</section>
"""
end

defp all_routes_with_green_line() do
all_routes = @routes_repo.all()

first_gl_index = all_routes |> Enum.find_index(&(&1.line_id == "line-Green"))

all_routes |> List.insert_at(first_gl_index, @routes_repo.green_line())
end
end
23 changes: 6 additions & 17 deletions lib/dotcom_web/live/schedule_finder_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ defmodule DotcomWeb.ScheduleFinderLive do
<.upcoming_departures_table
:if={@stop}
now={@now}
route={@route}
stop_id={@stop.id}
upcoming_departures={@upcoming_departures |> Enum.take(5)}
vehicle_name={@vehicle_name}
Expand Down Expand Up @@ -449,21 +448,11 @@ defmodule DotcomWeb.ScheduleFinderLive do
end

attr :now, DateTime
attr :route, Route
attr :stop_id, :string
attr :upcoming_departures, :list
attr :vehicle_name, :string

defp upcoming_departures_table(assigns) do
mode = assigns.route |> Route.type_atom() |> atom_to_class()
line_name = assigns.route |> Route.icon_atom() |> atom_to_class()

assigns =
assign(assigns, %{
line_name: line_name,
mode: mode
})

~H"""
<div class="divide-y-xs divide-gray-lightest border-xs border-gray-lightest">
<.unstyled_accordion
Expand All @@ -473,7 +462,7 @@ defmodule DotcomWeb.ScheduleFinderLive do
>
<:heading>
<div class="w-full flex gap-2">
<RouteComponents.route_icon size="small" route={@route} />
<RouteComponents.route_icon size="small" route={upcoming_departure.route} />
<div>{upcoming_departure.headsign}</div>
<div class="ml-auto">
<.prediction_time_display arrival_status={upcoming_departure.arrival_status} />
Expand All @@ -482,15 +471,15 @@ defmodule DotcomWeb.ScheduleFinderLive do
</:heading>
<:content>
<.lined_list>
<.lined_list_item route={@route} variant="mode">
<.lined_list_item route={upcoming_departure.route} variant="mode">
<div class="grow">Hello we are your {@vehicle_name}</div>
</.lined_list_item>
<details
:if={Enum.count(upcoming_departure.trip_details.stops_before) > 0}
class="group/details"
>
<summary class="cursor-pointer">
<.lined_list_item route={@route} variant="none">
<.lined_list_item route={upcoming_departure.route} variant="none">
<div class="grow">
{ngettext(
"1 Stop Away",
Expand All @@ -507,20 +496,20 @@ defmodule DotcomWeb.ScheduleFinderLive do
:for={other_stop <- upcoming_departure.trip_details.stops_before}
class="border-t-xs border-gray-lightest"
other_stop={other_stop}
route={@route}
route={upcoming_departure.route}
stop_id={@stop_id}
/>
</details>

<.other_stop
other_stop={upcoming_departure.trip_details.stop}
route={@route}
route={upcoming_departure.route}
stop_id={@stop_id}
/>
<.other_stop
:for={other_stop <- upcoming_departure.trip_details.stops_after}
other_stop={other_stop}
route={@route}
route={upcoming_departure.route}
stop_id={@stop_id}
/>
</.lined_list>
Expand Down
9 changes: 9 additions & 0 deletions lib/predictions/repo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ defmodule Predictions.Repo do
_ = Logger.info("predictions_repo_all_cache=call")

opts
|> update_green_line_route_id()
|> add_all_optional_params()
|> cache_fetch()
|> filter_predictions(Keyword.take(opts, [:min_time, :include_terminals]))
|> load_from_other_repos
end

defp update_green_line_route_id(opts) do
if opts |> Keyword.get(:route) == "Green" do
opts |> Keyword.put(:route, GreenLine.branch_ids() |> Enum.join(","))
else
opts
end
end

defp add_all_optional_params(opts) do
@default_params
|> add_optional_param(opts, :route)
Expand Down
Loading