Skip to content

Commit

Permalink
Rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky committed Jul 18, 2019
1 parent 84e61ea commit 0d31909
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/site/lib/site_web/controllers/schedule/schedule_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ defmodule SiteWeb.ScheduleController.ScheduleApi do

@spec get_schedules(binary, any, any) :: %{by_trip: map, trip_order: [any]}
def get_schedules(route_id, date, direction_id) do
services =
schedules =
Enum.map(
Schedules.Repo.by_route_ids([route_id], date: date, direction_id: direction_id),
&Map.update!(&1, :route, fn route -> Routes.Route.to_json_safe(route) end)
)

services_by_trip =
services
schedules_by_trip =
schedules
|> Enum.map(&Map.update!(&1, :time, fn time -> Timex.format!(time, "{0h12}:{m} {AM}") end))
|> Enum.group_by(& &1.trip.id)

ordered_trips = services |> Enum.sort_by(& &1.time) |> Enum.map(& &1.trip.id) |> Enum.uniq()
%{by_trip: services_by_trip, trip_order: ordered_trips}
ordered_trips = schedules |> Enum.sort_by(& &1.time) |> Enum.map(& &1.trip.id) |> Enum.uniq()
%{by_trip: schedules_by_trip, trip_order: ordered_trips}
end
end

0 comments on commit 0d31909

Please sign in to comment.