Skip to content

Commit

Permalink
Merge pull request #2 from mbta/jdl/allow-user-to-specify-number-of-i…
Browse files Browse the repository at this point in the history
…tineraries

Allow user to specify number of itineraries
  • Loading branch information
thecristen authored Dec 3, 2024
2 parents da20df3 + e65877a commit daab77a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/open_trip_planner_client/plan_params.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule OpenTripPlannerClient.PlanParams do
:date,
:time,
arriveBy: false,
numItineraries: 5,
transportModes: [%{mode: :WALK}, %{mode: :TRANSIT}],
wheelchair: false
]
Expand Down Expand Up @@ -101,6 +102,7 @@ defmodule OpenTripPlannerClient.PlanParams do
arriveBy: arrive_by(),
fromPlace: place(),
date: date(),
numItineraries: integer(),
time: time(),
toPlace: place(),
transportModes: transport_modes(),
Expand Down
3 changes: 2 additions & 1 deletion priv/plan.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ query TripPlan(
$arriveBy: Boolean
$wheelchair: Boolean
$transportModes: [TransportMode]
$numItineraries: Int
) {
plan(
fromPlace: $fromPlace
Expand All @@ -20,7 +21,7 @@ query TripPlan(
searchWindow: 7200

# Increased from 3 to offer more itineraries for potential post-processing
numItineraries: 5
numItineraries: $numItineraries

# Increased from 2.0 to reduce number of itineraries with significant walking
walkReluctance: 5.0
Expand Down
12 changes: 12 additions & 0 deletions test/open_trip_planner_client/plan_params_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ defmodule OpenTripPlannerClient.PlanParamsTest do
assert to_time_param(now) == time
end

test "new/1 defaults to having 5 itineraries" do
assert %OpenTripPlannerClient.PlanParams{
numItineraries: 5
} = new()
end

test "new/1 allows a customizable number of itineraries" do
assert %OpenTripPlannerClient.PlanParams{
numItineraries: 42
} = new(%{numItineraries: 42})
end

test "to_place_param/1 with stop" do
name = Faker.App.name()
stop_id = Faker.Internet.slug()
Expand Down

0 comments on commit daab77a

Please sign in to comment.