Skip to content

Commit

Permalink
fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeheft committed Jul 7, 2024
1 parent 0c7032e commit f6dfa42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 10 additions & 12 deletions lib/rides/commands/get_routes_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,18 @@ def call(rides:)
data = data.select { _1[:originIndex] == _1[:destinationIndex] }
data = transform_keys!(data)

combine_routes_data!(data)
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)
data.map.with_index do |d, idx|
ride = rides[idx]

# 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.
OpenStruct.new(
ride_id: ride.id,
from_address_id: ride.from_address&.id,
from_address: ride.from_address,
to_address: ride.to_address,
to_address_id: ride.to_address&.id,
**d
)
OpenStruct.new(ride_id: ride.id, from_address_id: ride.from_address&.id,
from_address: ride.from_address, to_address: ride.to_address,
to_address_id: ride.to_address&.id, **d)
end
end

Expand Down
6 changes: 6 additions & 0 deletions lib/rides/commands/rank_rides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def call(driver:)
"Please check the ride(s) configuration and try again."
end

combine_rides!(rides)
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)
rides.map.with_index do |ride, idx|
commute = commutes.fetch(idx)
commute_duration = commute.duration
Expand Down

0 comments on commit f6dfa42

Please sign in to comment.