9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/generators/templates/req_res_stat_controller.rb', line 9
def get_stats
stat_key = params[:stat_key].to_sym
start_time = parse_date_time_zone params[:start_time]
end_time = parse_date_time_zone params[:end_time]
granularity_in_hours = params[:granularity_in_hours].to_i.hours if params[:granularity_in_hours].present?
min_values = ReqResStat.get_min(stat_key, start_time, end_time, granularity_in_hours)
max_values = ReqResStat.get_max(stat_key, start_time, end_time, granularity_in_hours)
avg_values = ReqResStat.get_avg(stat_key, start_time, end_time, granularity_in_hours)
return_value = {
start_time: start_time,
end_time: end_time,
granularity_in_hours: granularity_in_hours,
min_values: min_values,
max_values: max_values,
avg_values: avg_values,
}
render json: return_value
rescue Exception => ex
error_message = [ex.message, ex.backtrace.join("\n")].join("\n")
render json: {error_message: error_message}
end
|