Skip to content

Commit

Permalink
Add slow-ass join on airport info
Browse files Browse the repository at this point in the history
  • Loading branch information
YourFin committed Jan 10, 2020
1 parent 2718e65 commit 74d3905
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/services/flights/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ def find_flight(date:,
}.compact!
@client.call(:airline_flight_schedules, message: message)
&.to_hash[:airline_flight_schedules_results][:airline_flight_schedules_result][:data]
.map do |flight|
flight[:departuretime] = Time.at(flight[:departuretime].to_i)
flight[:arrivaltime] = Time.at(flight[:arrivaltime].to_i)
flight[:origin] = _get_airport_info(flight[:origin])
flight[:destination] = _get_airport_info(flight[:destination])
flight
end
end

def _get_airport_info(shortcode)
resp = @client.call(:airport_info, message: {airport_code: shortcode})
resp.to_hash[:airport_info_results][:airport_info_result]
end

def _get_airline_info(shortcode)
@client.call(:airline_info, message: {airline_code: shortcode})
end

# Converts a Time object into [8 pm night before, 4am next day] in an attempt
Expand Down

0 comments on commit 74d3905

Please sign in to comment.