fix /filter api - prevent error on exception conditions
This commit is contained in:
parent
9b59ef6121
commit
286841c3d0
|
|
@ -18,7 +18,11 @@ module JamRuby
|
|||
limit = [params[:limit].to_i, 20].max
|
||||
filter_params = {}
|
||||
|
||||
filter_params.merge!(from_location: params[:from_location] ? '1' : '0')
|
||||
if params[:from_location].present? && params[:from_location].to_s == 'true'
|
||||
filter_params.merge!(from_location: "1")
|
||||
else
|
||||
filter_params.merge!(from_location: "0")
|
||||
end
|
||||
|
||||
genres = params[:genres]
|
||||
filter_params.merge!(genres: genres) if genres
|
||||
|
|
@ -68,14 +72,14 @@ module JamRuby
|
|||
[search, latency_data, nextOffset]
|
||||
|
||||
rescue => exception
|
||||
logger.debug("Latency exception: #{exception.message}")
|
||||
#logger.debug("Latency exception: #{exception.message}")
|
||||
Bugsnag.notify(exception) do |report|
|
||||
report.severity = "error"
|
||||
report.add_tab(:latency, {
|
||||
params: params,
|
||||
user_id: user.id,
|
||||
name: user.name,
|
||||
url: filter_latency_url,
|
||||
url: latency_url,
|
||||
})
|
||||
end
|
||||
raise exception
|
||||
|
|
@ -83,9 +87,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
def self.users_latency_data(user_obj, remote_ip, latency_good, latency_fair, latency_high, filter_opts, offset, limit)
|
||||
filter_latency_url = "#{APP_CONFIG.latency_data_host}/search_users"
|
||||
|
||||
uri = URI(filter_latency_url)
|
||||
uri = URI(latency_url)
|
||||
begin
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true if APP_CONFIG.latency_data_host.start_with?("https://")
|
||||
|
|
@ -138,22 +140,29 @@ module JamRuby
|
|||
|
||||
return { data: latency_data, next: nextOffset }
|
||||
else
|
||||
logger.debug("Latency response failed: #{response}")
|
||||
Bugsnag.notify("LatencyResponseFailed") do |report|
|
||||
report.severity = "faliure"
|
||||
report.add_tab(:latency, {
|
||||
user_id: user_obj.id,
|
||||
name: user_obj.name,
|
||||
params: params,
|
||||
url: filter_latency_url,
|
||||
params: req_params,
|
||||
url: latency_url,
|
||||
code: response.code,
|
||||
body: response.body,
|
||||
})
|
||||
end
|
||||
Rails.logger.debug("Latency response failed: #{response.code} #{response.body}")
|
||||
raise Exception.new("#{response.code}: #{response.body}")
|
||||
end
|
||||
rescue => exception
|
||||
raise exception
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.latency_url
|
||||
"#{APP_CONFIG.latency_data_host}/client#"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -181,10 +181,9 @@ class ApiSearchController < ApiController
|
|||
def filter
|
||||
begin
|
||||
@search, @latency_data, @nextOffset = JamRuby::MusicianFilter.filter(current_user, request.remote_ip, params)
|
||||
Rails.logger.debug("=====SEARCH : #{@search.results.inspect}")
|
||||
Rails.logger.debug("=====LATENCY : #{@latency_data}")
|
||||
respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/filter'
|
||||
rescue
|
||||
rescue => ex
|
||||
Rails.logger.debug("=====LATENCY EXCEPTION : #{ex.message}")
|
||||
render json: {}, status: 500
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue