Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions #92

Merged
merged 2 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion app/controllers/stops_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class StopsController < ApplicationController
def show
@region = Region.find_by!(region_identifier: params[:region_id])
redirect_to File.join(@region.web_url, "/where/standard/stop.action?id=#{params[:id]}")
redirect_to File.join(@region.web_url, "/where/standard/stop.action?id=#{params[:id]}", allow_other_host: true)
end

def trips
Expand Down
10 changes: 7 additions & 3 deletions app/lib/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ def arrivals_and_departures(stop_id:, minutes_before: 5, minutes_after: 35)
# @param trip_id [String]
# @param vehicle_id [String] (`nil`)
def arrival_and_departure(stop_id:, service_date:, stop_sequence:, trip_id:, vehicle_id:)
url = build_arrival_and_departure_url(stop_id: stop_id, service_date: service_date, stop_sequence: stop_sequence,
url = build_arrival_and_departure_url(stop_id: stop_id, service_date: service_date, stop_sequence: stop_sequence,
trip_id: trip_id, vehicle_id: vehicle_id)
response = RestClient.get(url)

raise ObaErrors::EmptyServerResponse if response.body.blank?

json = JSON.parse(response.body)
arr_dep = ArrivalDeparture.from_json(json['data']['entry'])
entry = json.dig('data', 'entry')

raise ObaErrors::EmptyServerResponse unless entry

arr_dep = ArrivalDeparture.from_json(entry)
arr_dep.current_server_time = json["currentTime"]
return arr_dep
arr_dep
end

# @param service_date [Integer]
Expand Down
Loading