/
performances_controller.rb
35 lines (32 loc) · 1.28 KB
/
performances_controller.rb
1
2
3
4
5
6
7
8
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
34
35
module Concen
class PerformancesController < Concen::ApplicationController
def show
@page_title = "Performance"
end
def responses
@stats = {}
@stats[:total_runtime] = Response.where(:created_at.gte => Time.now - 1.hour).asc(:created_at).map do |response|
[(response.created_at.utc.to_f + response.created_at.utc_offset)*1000, response.total_runtime]
end
@stats[:view_runtime] = Response.where(:created_at.gte => Time.now - 1.hour).asc(:created_at).map do |response|
if response.respond_to?("view_runtime")
[(response.created_at.utc.to_f + response.created_at.utc_offset)*1000, response.view_runtime]
end
end
@stats[:mongo_runtime] = Response.where(:created_at.gte => Time.now - 1.hour).asc(:created_at).map do |response|
if response.respond_to?("mongo_runtime")
[(response.created_at.utc.to_f + response.created_at.utc_offset)*1000, response.mongo_runtime]
end
end
respond_to do |format|
format.json { render :json => @stats }
end
end
def runtimes
@runtimes_stats = Response.aggregate_average_runtime(:type => params[:type])
respond_to do |format|
format.html { render :partial => "concen/performances/runtimes" }
end
end
end
end