Class: RailsPerformance::RailsPerformanceController

Inherits:
BaseController
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/controllers/rails_performance/rails_performance_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#active?, #bot_icon, #duraction_alert_class, #extract_duration, #format_datetime, #icon, #insert_css_file, #insert_js_file, #link_to_path, #ms, #mss, #report_name, #round_it, #short_path, #status_tag

Instance Method Details

#crashesObject



41
42
43
44
45
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 41

def crashes
  @datasource   = RailsPerformance::DataSource.new(**prepare_query({status_eq: 500}), type: :requests)
  db            = @datasource.db
  @data         = RailsPerformance::Reports::CrashReport.new(db).data
end

#customObject



105
106
107
108
109
110
111
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 105

def custom
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :custom)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#delayed_jobObject



97
98
99
100
101
102
103
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 97

def delayed_job
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :delayed_job)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#grapeObject



113
114
115
116
117
118
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 113

def grape
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :grape)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#indexObject



10
11
12
13
14
15
16
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 10

def index
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db                         = @datasource.db

  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
end

#rakeObject



120
121
122
123
124
125
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 120

def rake
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :rake)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#recentObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 53

def recent
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::RecentRequestsReport.new(db).data(params[:from_timei])

  # example
  # :controller=>"HomeController",
  # :action=>"index",
  # :format=>"html",
  # :status=>"200",
  # :method=>"GET",
  # :path=>"/",
  # :request_id=>"9c9bff5f792a5b3f77cb07fa325f8ddf",
  # :datetime=>2023-06-24 21:22:46 +0300,
  # :datetimei=>1687630966,
  # :duration=>207.225830078125,
  # :db_runtime=>2.055999994277954,
  # :view_runtime=>67.8370000096038,
  # :exception=>nil,
  # :backtrace=>nil,
  # :http_referer=>nil,
  # "email"=>nil,
  # "user_agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"}]

  respond_to do |page|
    page.html
    page.js
  end
end

#requestsObject



47
48
49
50
51
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 47

def requests
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count).data
end

#sidekiqObject



89
90
91
92
93
94
95
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 89

def sidekiq
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :sidekiq)
  db                         = @datasource.db
  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @recent_report_data        = RailsPerformance::Reports::RecentRequestsReport.new(db).data
end

#slowObject



83
84
85
86
87
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 83

def slow
  @datasource = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db          = @datasource.db
  @data       = RailsPerformance::Reports::SlowRequestsReport.new(db).data
end

#summaryObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 18

def summary
  @datasource                = RailsPerformance::DataSource.new(**prepare_query, type: :requests)
  db                         = @datasource.db

  @throughput_report_data    = RailsPerformance::Reports::ThroughputReport.new(db).data
  @response_time_report_data = RailsPerformance::Reports::ResponseTimeReport.new(db).data
  @data                      = RailsPerformance::Reports::BreakdownReport.new(db, title: "Requests").data

  respond_to do |format|
    format.js {}
    format.any { render plain: "Doesn't open in new window. Wait until full page load." }
  end
end

#traceObject



32
33
34
35
36
37
38
39
# File 'app/controllers/rails_performance/rails_performance_controller.rb', line 32

def trace
  @record = RailsPerformance::Models::RequestRecord.find_by(request_id: params[:id])
  @data   = RailsPerformance::Reports::TraceReport.new(request_id: params[:id]).data
  respond_to do |format|
    format.js {}
    format.any { render plain: "Doesn't open in new window. Wait until full page load." }
  end
end