diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 815cb1d..aadf6ca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,10 +5,10 @@ class ApplicationController < ActionController::API params.permit(:limit, :offset) end private def limit - pagination_params[:limit]&.to_i || 2 + pagination_params[:limit] || 2 end private def offset - pagination_params[:offset]&.to_i || 0 + pagination_params[:offset] || 0 end end diff --git a/lib/rides/commands/get_routes_data.rb b/lib/rides/commands/get_routes_data.rb index f0342d1..659147c 100644 --- a/lib/rides/commands/get_routes_data.rb +++ b/lib/rides/commands/get_routes_data.rb @@ -33,13 +33,13 @@ def call(rides:) data = data.select { _1[:originIndex] == _1[:destinationIndex] } data = transform_keys!(data) - combine_routes_data!(data) + combine_routes_data!(data, rides) end # The manner in which jsonapi-serializer serialzies pojos, # in order to adhere to the json api spec, we need to define # the id _and_ the object iteself. - private def combine_routes_data!(data) + private def combine_routes_data!(data, rides) data.map.with_index do |d, idx| ride = rides[idx] OpenStruct.new(ride_id: ride.id, from_address_id: ride.from_address&.id, diff --git a/lib/rides/commands/rank_rides.rb b/lib/rides/commands/rank_rides.rb index c1b7103..e125ef8 100644 --- a/lib/rides/commands/rank_rides.rb +++ b/lib/rides/commands/rank_rides.rb @@ -47,12 +47,12 @@ def call(driver:) "Please check the ride(s) configuration and try again." end - combine_rides!(rides) + combine_rides!(rides, commutes) end # Combines the duration data for the driver to get to the start of the ride # with that of the ride's data, e.g., duration, distance - private def combine_rides!(rides) + private def combine_rides!(rides, commutes) rides.map.with_index do |ride, idx| commute = commutes.fetch(idx) commute_duration = commute.duration