Skip to content
Merged
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
21 changes: 17 additions & 4 deletions lib/dotcom_web/controllers/schedule/finder_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ defmodule DotcomWeb.ScheduleController.FinderApi do

# Leverage the JourneyList module to return a simplified set of trips
@spec journeys(Plug.Conn.t(), map) :: Plug.Conn.t()
def journeys(conn, %{"stop" => stop_id, "date" => date} = params) do
def journeys(
conn,
%{
"stop" => stop_id,
"date" => date,
"is_current" => is_current,
"id" => _id,
"direction" => _direction
} = params
) do
{:ok, user_selected_date} = Date.from_iso8601(date)
{schedules, predictions} = load_from_repos(conn, params)

Expand All @@ -52,7 +61,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do
# matching the design spec architecturally better than the existing
# Schedules-only and Predictions-only configuration for
# ScheduleFinder.
today? = params["is_current"] == "true"
today? = is_current == "true"
current_time = if today?, do: user_selected_date, else: nil

journey_list_opts = [
Expand All @@ -68,6 +77,10 @@ defmodule DotcomWeb.ScheduleController.FinderApi do
json(conn, journeys)
end

def journeys(conn, _) do
return_invalid_arguments_error(conn)
end

# Use alternative JourneyList constructor to only return trips with predictions
@spec departures(Plug.Conn.t(), map) :: Plug.Conn.t()
def departures(conn, %{"stop" => stop_id} = params) do
Expand All @@ -87,7 +100,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do
end

def departures(conn, _) do
ControllerHelpers.return_invalid_arguments_error(conn)
return_invalid_arguments_error(conn)
Comment thread
lvachon1 marked this conversation as resolved.
end

@spec get_trip_info(Plug.Conn.t(), Trip.id_t(), Route.t(), String.t(), String.t(), String.t()) ::
Expand Down Expand Up @@ -171,7 +184,7 @@ defmodule DotcomWeb.ScheduleController.FinderApi do
end

def trip(conn, _) do
ControllerHelpers.return_invalid_arguments_error(conn)
return_invalid_arguments_error(conn)
end

# Use internal API to generate list of relevant schedules and predictions
Expand Down
Loading