rails_performance 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/rails_performance/base_controller.rb +21 -0
- data/app/controllers/rails_performance/rails_performance_controller.rb +91 -0
- data/app/helpers/rails_performance/application_helper.rb +116 -0
- data/app/views/rails_performance/{_summary.html.erb → rails_performance/_summary.html.erb} +0 -0
- data/app/views/rails_performance/{_trace.html.erb → rails_performance/_trace.html.erb} +0 -0
- data/app/views/rails_performance/{crashes.html.erb → rails_performance/crashes.html.erb} +0 -0
- data/app/views/rails_performance/{index.html.erb → rails_performance/index.html.erb} +0 -0
- data/app/views/rails_performance/{jobs.html.erb → rails_performance/jobs.html.erb} +0 -0
- data/app/views/rails_performance/{recent.html.erb → rails_performance/recent.html.erb} +0 -0
- data/app/views/rails_performance/{requests.html.erb → rails_performance/requests.html.erb} +0 -0
- data/app/views/rails_performance/{summary.js.erb → rails_performance/summary.js.erb} +1 -1
- data/app/views/rails_performance/{trace.js.erb → rails_performance/trace.js.erb} +1 -1
- data/lib/rails_performance/engine.rb +1 -0
- data/lib/rails_performance/version.rb +1 -1
- metadata +14 -14
- data/app/controllers/base_controller.rb +0 -19
- data/app/controllers/rails_performance_controller.rb +0 -88
- data/app/helpers/rails_performance_helper.rb +0 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91dc41ef53b796c8c0755afd109fc7b7684ea9a5567828ab0e7f9e6c80cf9e79
|
4
|
+
data.tar.gz: 434e5e19a7abb0fc86b094d591623d626ab4b8a8e2ad28b70d2dfe70583e510b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dffbb9eab0930f214009a8717c97a9fe82b7ea5fea22cd7a18d9a34426811d8467a19600e38e5fbdc1eb4c1aee1308b7819a8b79ff77d721907a644b9f2facea
|
7
|
+
data.tar.gz: 69e08649d416bf680f203ee801534c1c5dbedd5ee956e85cca5439db3eaa8062ca830800454eb37335059732239946f6a39ad0a1d756b7efa40864fc5ebb9dc9
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RailsPerformance
|
2
|
+
class BaseController < ActionController::Base
|
3
|
+
layout 'rails_performance/layouts/rails_performance'
|
4
|
+
|
5
|
+
before_action :verify_access
|
6
|
+
|
7
|
+
if RailsPerformance.http_basic_authentication_enabled
|
8
|
+
http_basic_authenticate_with \
|
9
|
+
name: RailsPerformance.http_basic_authentication_user_name,
|
10
|
+
password: RailsPerformance.http_basic_authentication_password
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def verify_access
|
16
|
+
result = RailsPerformance.verify_access_proc.call(self)
|
17
|
+
redirect_to('/', error: 'Access Denied', status: 401) unless result
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative './base_controller.rb'
|
2
|
+
|
3
|
+
module RailsPerformance
|
4
|
+
class RailsPerformanceController < RailsPerformance::BaseController
|
5
|
+
include RailsPerformance::ApplicationHelper
|
6
|
+
|
7
|
+
if RailsPerformance.enabled
|
8
|
+
def index
|
9
|
+
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
10
|
+
db = @datasource.db
|
11
|
+
|
12
|
+
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
13
|
+
@throughput_report_data = @throughput_report.data
|
14
|
+
|
15
|
+
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
16
|
+
@response_time_report_data = @response_time_report.data
|
17
|
+
end
|
18
|
+
|
19
|
+
def summary
|
20
|
+
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
21
|
+
db = @datasource.db
|
22
|
+
|
23
|
+
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
24
|
+
@throughput_report_data = @throughput_report.data
|
25
|
+
|
26
|
+
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
27
|
+
@response_time_report_data = @response_time_report.data
|
28
|
+
|
29
|
+
@report = RP::Reports::BreakdownReport.new(db, title: "Requests")
|
30
|
+
@data = @report.data
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
format.js {}
|
34
|
+
format.any { render plain: "Doesn't open in new window. Wait until full page load." }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def trace
|
39
|
+
@record = RP::Models::Record.find_by(request_id: params[:id])
|
40
|
+
@report = RP::Reports::TraceReport.new(request_id: params[:id])
|
41
|
+
@data = @report.data
|
42
|
+
respond_to do |format|
|
43
|
+
format.js {}
|
44
|
+
format.any { render plain: "Doesn't open in new window. Wait until full page load." }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def crashes
|
49
|
+
@datasource = RP::DataSource.new(**prepare_query({status_eq: 500}), type: :requests, klass: RP::Models::Record)
|
50
|
+
db = @datasource.db
|
51
|
+
@report = RP::Reports::CrashReport.new(db)
|
52
|
+
@data = @report.data
|
53
|
+
end
|
54
|
+
|
55
|
+
def requests
|
56
|
+
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
57
|
+
db = @datasource.db
|
58
|
+
@report = RP::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count)
|
59
|
+
@data = @report.data
|
60
|
+
end
|
61
|
+
|
62
|
+
def recent
|
63
|
+
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
64
|
+
db = @datasource.db
|
65
|
+
@report = RP::Reports::RecentRequestsReport.new(db)
|
66
|
+
@data = @report.data
|
67
|
+
end
|
68
|
+
|
69
|
+
def jobs
|
70
|
+
@datasource = RP::DataSource.new(**prepare_query, type: :jobs, klass: RP::Models::JobRecord)
|
71
|
+
db = @datasource.db
|
72
|
+
|
73
|
+
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
74
|
+
@throughput_report_data = @throughput_report.data
|
75
|
+
|
76
|
+
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
77
|
+
@response_time_report_data = @response_time_report.data
|
78
|
+
|
79
|
+
@recent_report = RP::Reports::RecentRequestsReport.new(db)
|
80
|
+
@recent_report_data = @recent_report.data(:jobs)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def prepare_query(query = params)
|
86
|
+
RP::Rails::QueryBuilder.compose_from(query)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module RailsPerformance
|
2
|
+
module ApplicationHelper
|
3
|
+
def round_it(value)
|
4
|
+
return nil unless value
|
5
|
+
return value if value.is_a?(Integer)
|
6
|
+
|
7
|
+
value.nan? ? nil : value.round(1)
|
8
|
+
end
|
9
|
+
|
10
|
+
def duraction_alert_class(duration_str)
|
11
|
+
if duration_str.to_s =~ /(\d+.?\d+?)/
|
12
|
+
duration = $1.to_f
|
13
|
+
if duration >= 500
|
14
|
+
'has-background-danger has-text-white-bis'
|
15
|
+
elsif duration >= 200
|
16
|
+
'has-background-warning has-text-black-ter'
|
17
|
+
else
|
18
|
+
'has-background-success has-text-white-bis'
|
19
|
+
end
|
20
|
+
else
|
21
|
+
'has-background-light'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def extract_duration(str)
|
26
|
+
if (str =~ /Duration: (\d+.?\d+?ms)/i)
|
27
|
+
$1
|
28
|
+
else
|
29
|
+
'-'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def ms(value)
|
34
|
+
result = round_it(value)
|
35
|
+
result && result != 0 ? "#{result} ms" : '-'
|
36
|
+
end
|
37
|
+
|
38
|
+
def short_path(path, length: 60)
|
39
|
+
content_tag :span, title: path do
|
40
|
+
truncate(path, length: length)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def link_to_path(e)
|
45
|
+
if e[:method] == 'GET'
|
46
|
+
link_to(short_path(e[:path]), e[:path], target: '_blank')
|
47
|
+
else
|
48
|
+
short_path(e[:path])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def report_name(h)
|
53
|
+
h.except(:on).collect do |k, v|
|
54
|
+
next if v.blank?
|
55
|
+
|
56
|
+
%Q{
|
57
|
+
<div class="control">
|
58
|
+
<span class="tags has-addons">
|
59
|
+
<span class="tag">#{k}</span>
|
60
|
+
<span class="tag is-info is-light">#{v}</span>
|
61
|
+
</span>
|
62
|
+
</div>}
|
63
|
+
end.compact.join.html_safe
|
64
|
+
end
|
65
|
+
|
66
|
+
def status_tag(status)
|
67
|
+
klass = case status.to_s
|
68
|
+
when /^5/
|
69
|
+
"tag is-danger"
|
70
|
+
when /^4/
|
71
|
+
"tag is-warning"
|
72
|
+
when /^3/
|
73
|
+
"tag is-info"
|
74
|
+
when /^2/
|
75
|
+
"tag is-success"
|
76
|
+
else
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
content_tag(:span, class: klass) do
|
80
|
+
status
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def icon(name)
|
85
|
+
# https://www.iconfinder.com/iconsets/vivid
|
86
|
+
raw File.read(File.expand_path(File.dirname(__FILE__) + "/../../assets/images/#{name}.svg"))
|
87
|
+
end
|
88
|
+
|
89
|
+
def insert_css_file(file)
|
90
|
+
raw "<style>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../../views/rails_performance/stylesheets/#{file}")}</style>"
|
91
|
+
end
|
92
|
+
|
93
|
+
def insert_js_file(file)
|
94
|
+
raw "<script>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../../views/rails_performance/javascripts/#{file}")}</script>"
|
95
|
+
end
|
96
|
+
|
97
|
+
def format_datetime(e)
|
98
|
+
e.strftime("%Y-%m-%d %H:%M:%S")
|
99
|
+
end
|
100
|
+
|
101
|
+
def active?(section)
|
102
|
+
case section
|
103
|
+
when :dashboard
|
104
|
+
"is-active" if controller_name == "rails_performance" && action_name == "index"
|
105
|
+
when :crashes
|
106
|
+
"is-active" if controller_name == "rails_performance" && action_name == "crashes"
|
107
|
+
when :requests
|
108
|
+
"is-active" if controller_name == "rails_performance" && action_name == "requests"
|
109
|
+
when :recent
|
110
|
+
"is-active" if controller_name == "rails_performance" && action_name == "recent"
|
111
|
+
when :jobs
|
112
|
+
"is-active" if controller_name == "rails_performance" && action_name == "jobs"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
window.panel.header.html(window.panel.close + '<%= j report_name(@datasource.q) %>');
|
2
|
-
window.panel.content.html("<%= j render '/rails_performance/summary' %>");
|
2
|
+
window.panel.content.html("<%= j render '/rails_performance/rails_performance/summary' %>");
|
3
3
|
|
4
4
|
var data1 = <%= raw @throughput_report_data.to_json %>;
|
5
5
|
showTIRChart('throughput_report_chart_mini', data1, ' rpm', 'RPM');
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -115,14 +115,10 @@ files:
|
|
115
115
|
- app/assets/images/import.svg
|
116
116
|
- app/assets/images/menu.svg
|
117
117
|
- app/assets/images/stat.svg
|
118
|
-
- app/controllers/base_controller.rb
|
119
|
-
- app/controllers/rails_performance_controller.rb
|
120
|
-
- app/helpers/
|
118
|
+
- app/controllers/rails_performance/base_controller.rb
|
119
|
+
- app/controllers/rails_performance/rails_performance_controller.rb
|
120
|
+
- app/helpers/rails_performance/application_helper.rb
|
121
121
|
- app/views/rails_performance/_panel.html.erb
|
122
|
-
- app/views/rails_performance/_summary.html.erb
|
123
|
-
- app/views/rails_performance/_trace.html.erb
|
124
|
-
- app/views/rails_performance/crashes.html.erb
|
125
|
-
- app/views/rails_performance/index.html.erb
|
126
122
|
- app/views/rails_performance/javascripts/_javascripts.html.erb
|
127
123
|
- app/views/rails_performance/javascripts/app.js
|
128
124
|
- app/views/rails_performance/javascripts/jquery-3.4.1.min.js
|
@@ -130,17 +126,21 @@ files:
|
|
130
126
|
- app/views/rails_performance/javascripts/rails.js
|
131
127
|
- app/views/rails_performance/javascripts/stupidtable.min.js
|
132
128
|
- app/views/rails_performance/javascripts/table.js
|
133
|
-
- app/views/rails_performance/jobs.html.erb
|
134
129
|
- app/views/rails_performance/layouts/rails_performance.html.erb
|
135
|
-
- app/views/rails_performance/
|
136
|
-
- app/views/rails_performance/
|
130
|
+
- app/views/rails_performance/rails_performance/_summary.html.erb
|
131
|
+
- app/views/rails_performance/rails_performance/_trace.html.erb
|
132
|
+
- app/views/rails_performance/rails_performance/crashes.html.erb
|
133
|
+
- app/views/rails_performance/rails_performance/index.html.erb
|
134
|
+
- app/views/rails_performance/rails_performance/jobs.html.erb
|
135
|
+
- app/views/rails_performance/rails_performance/recent.html.erb
|
136
|
+
- app/views/rails_performance/rails_performance/requests.html.erb
|
137
|
+
- app/views/rails_performance/rails_performance/summary.js.erb
|
138
|
+
- app/views/rails_performance/rails_performance/trace.js.erb
|
137
139
|
- app/views/rails_performance/shared/_header.html.erb
|
138
140
|
- app/views/rails_performance/stylesheets/_stylesheets.html.erb
|
139
141
|
- app/views/rails_performance/stylesheets/bulma.min.css
|
140
142
|
- app/views/rails_performance/stylesheets/panel.css
|
141
143
|
- app/views/rails_performance/stylesheets/style.css
|
142
|
-
- app/views/rails_performance/summary.js.erb
|
143
|
-
- app/views/rails_performance/trace.js.erb
|
144
144
|
- config/routes.rb
|
145
145
|
- lib/rails_performance.rb
|
146
146
|
- lib/rails_performance/data_source.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class BaseController < ActionController::Base
|
2
|
-
layout 'rails_performance/layouts/rails_performance'
|
3
|
-
|
4
|
-
before_action :verify_access
|
5
|
-
|
6
|
-
if RailsPerformance.http_basic_authentication_enabled
|
7
|
-
http_basic_authenticate_with \
|
8
|
-
name: RailsPerformance.http_basic_authentication_user_name,
|
9
|
-
password: RailsPerformance.http_basic_authentication_password
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def verify_access
|
15
|
-
result = RailsPerformance.verify_access_proc.call(self)
|
16
|
-
redirect_to('/', error: 'Access Denied', status: 401) unless result
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require_relative './base_controller.rb'
|
2
|
-
|
3
|
-
class RailsPerformanceController < BaseController
|
4
|
-
|
5
|
-
if RailsPerformance.enabled
|
6
|
-
def index
|
7
|
-
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
8
|
-
db = @datasource.db
|
9
|
-
|
10
|
-
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
11
|
-
@throughput_report_data = @throughput_report.data
|
12
|
-
|
13
|
-
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
14
|
-
@response_time_report_data = @response_time_report.data
|
15
|
-
end
|
16
|
-
|
17
|
-
def summary
|
18
|
-
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
19
|
-
db = @datasource.db
|
20
|
-
|
21
|
-
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
22
|
-
@throughput_report_data = @throughput_report.data
|
23
|
-
|
24
|
-
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
25
|
-
@response_time_report_data = @response_time_report.data
|
26
|
-
|
27
|
-
@report = RP::Reports::BreakdownReport.new(db, title: "Requests")
|
28
|
-
@data = @report.data
|
29
|
-
|
30
|
-
respond_to do |format|
|
31
|
-
format.js {}
|
32
|
-
format.any { render plain: "Doesn't open in new window. Wait until full page load." }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def trace
|
37
|
-
@record = RP::Models::Record.find_by(request_id: params[:id])
|
38
|
-
@report = RP::Reports::TraceReport.new(request_id: params[:id])
|
39
|
-
@data = @report.data
|
40
|
-
respond_to do |format|
|
41
|
-
format.js {}
|
42
|
-
format.any { render plain: "Doesn't open in new window. Wait until full page load." }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def crashes
|
47
|
-
@datasource = RP::DataSource.new(**prepare_query({status_eq: 500}), type: :requests, klass: RP::Models::Record)
|
48
|
-
db = @datasource.db
|
49
|
-
@report = RP::Reports::CrashReport.new(db)
|
50
|
-
@data = @report.data
|
51
|
-
end
|
52
|
-
|
53
|
-
def requests
|
54
|
-
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
55
|
-
db = @datasource.db
|
56
|
-
@report = RP::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count)
|
57
|
-
@data = @report.data
|
58
|
-
end
|
59
|
-
|
60
|
-
def recent
|
61
|
-
@datasource = RP::DataSource.new(**prepare_query, type: :requests, klass: RP::Models::Record)
|
62
|
-
db = @datasource.db
|
63
|
-
@report = RP::Reports::RecentRequestsReport.new(db)
|
64
|
-
@data = @report.data
|
65
|
-
end
|
66
|
-
|
67
|
-
def jobs
|
68
|
-
@datasource = RP::DataSource.new(**prepare_query, type: :jobs, klass: RP::Models::JobRecord)
|
69
|
-
db = @datasource.db
|
70
|
-
|
71
|
-
@throughput_report = RP::Reports::ThroughputReport.new(db)
|
72
|
-
@throughput_report_data = @throughput_report.data
|
73
|
-
|
74
|
-
@response_time_report = RP::Reports::ResponseTimeReport.new(db)
|
75
|
-
@response_time_report_data = @response_time_report.data
|
76
|
-
|
77
|
-
@recent_report = RP::Reports::RecentRequestsReport.new(db)
|
78
|
-
@recent_report_data = @recent_report.data(:jobs)
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
def prepare_query(query = params)
|
84
|
-
RP::Rails::QueryBuilder.compose_from(query)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
module RailsPerformanceHelper
|
2
|
-
def round_it(value)
|
3
|
-
return nil unless value
|
4
|
-
return value if value.is_a?(Integer)
|
5
|
-
|
6
|
-
value.nan? ? nil : value.round(1)
|
7
|
-
end
|
8
|
-
|
9
|
-
def duraction_alert_class(duration_str)
|
10
|
-
if duration_str.to_s =~ /(\d+.?\d+?)/
|
11
|
-
duration = $1.to_f
|
12
|
-
if duration >= 500
|
13
|
-
'has-background-danger has-text-white-bis'
|
14
|
-
elsif duration >= 200
|
15
|
-
'has-background-warning has-text-black-ter'
|
16
|
-
else
|
17
|
-
'has-background-success has-text-white-bis'
|
18
|
-
end
|
19
|
-
else
|
20
|
-
'has-background-light'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def extract_duration(str)
|
25
|
-
if (str =~ /Duration: (\d+.?\d+?ms)/i)
|
26
|
-
$1
|
27
|
-
else
|
28
|
-
'-'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def ms(value)
|
33
|
-
result = round_it(value)
|
34
|
-
result && result != 0 ? "#{result} ms" : '-'
|
35
|
-
end
|
36
|
-
|
37
|
-
def short_path(path, length: 60)
|
38
|
-
content_tag :span, title: path do
|
39
|
-
truncate(path, length: length)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def link_to_path(e)
|
44
|
-
if e[:method] == 'GET'
|
45
|
-
link_to(short_path(e[:path]), e[:path], target: '_blank')
|
46
|
-
else
|
47
|
-
short_path(e[:path])
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def report_name(h)
|
52
|
-
h.except(:on).collect do |k, v|
|
53
|
-
next if v.blank?
|
54
|
-
|
55
|
-
%Q{
|
56
|
-
<div class="control">
|
57
|
-
<span class="tags has-addons">
|
58
|
-
<span class="tag">#{k}</span>
|
59
|
-
<span class="tag is-info is-light">#{v}</span>
|
60
|
-
</span>
|
61
|
-
</div>}
|
62
|
-
end.compact.join.html_safe
|
63
|
-
end
|
64
|
-
|
65
|
-
def status_tag(status)
|
66
|
-
klass = case status.to_s
|
67
|
-
when /^5/
|
68
|
-
"tag is-danger"
|
69
|
-
when /^4/
|
70
|
-
"tag is-warning"
|
71
|
-
when /^3/
|
72
|
-
"tag is-info"
|
73
|
-
when /^2/
|
74
|
-
"tag is-success"
|
75
|
-
else
|
76
|
-
nil
|
77
|
-
end
|
78
|
-
content_tag(:span, class: klass) do
|
79
|
-
status
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def icon(name)
|
84
|
-
# https://www.iconfinder.com/iconsets/vivid
|
85
|
-
raw File.read(File.expand_path(File.dirname(__FILE__) + "/../assets/images/#{name}.svg"))
|
86
|
-
end
|
87
|
-
|
88
|
-
def insert_css_file(file)
|
89
|
-
raw "<style>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/rails_performance/stylesheets/#{file}")}</style>"
|
90
|
-
end
|
91
|
-
|
92
|
-
def insert_js_file(file)
|
93
|
-
raw "<script>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/rails_performance/javascripts/#{file}")}</script>"
|
94
|
-
end
|
95
|
-
|
96
|
-
def format_datetime(e)
|
97
|
-
e.strftime("%Y-%m-%d %H:%M:%S")
|
98
|
-
end
|
99
|
-
|
100
|
-
def active?(section)
|
101
|
-
case section
|
102
|
-
when :dashboard
|
103
|
-
"is-active" if controller_name == "rails_performance" && action_name == "index"
|
104
|
-
when :crashes
|
105
|
-
"is-active" if controller_name == "rails_performance" && action_name == "crashes"
|
106
|
-
when :requests
|
107
|
-
"is-active" if controller_name == "rails_performance" && action_name == "requests"
|
108
|
-
when :recent
|
109
|
-
"is-active" if controller_name == "rails_performance" && action_name == "recent"
|
110
|
-
when :jobs
|
111
|
-
"is-active" if controller_name == "rails_performance" && action_name == "jobs"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|