rails_performance 1.2.0.alpha2 → 1.2.0.alpha4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/bot.svg +1 -0
- data/app/assets/images/user.svg +1 -0
- data/app/controllers/rails_performance/rails_performance_controller.rb +19 -0
- data/app/helpers/rails_performance/application_helper.rb +24 -2
- data/app/views/rails_performance/rails_performance/_recent_row.html.erb +1 -0
- data/app/views/rails_performance/rails_performance/recent.html.erb +1 -0
- data/app/views/rails_performance/rails_performance/slow.html.erb +1 -0
- data/app/views/rails_performance/stylesheets/style.css +5 -0
- data/lib/rails_performance/reports/response_time_report.rb +4 -4
- data/lib/rails_performance/reports/throughput_report.rb +6 -4
- data/lib/rails_performance/version.rb +1 -1
- data/lib/rails_performance.rb +1 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71e33d8156df40c792e33f03eae39a06c12f1622aa2c8071291c4e81c803d3ac
|
4
|
+
data.tar.gz: 288c78335fec92abede6d72f82b841fd128ff079baad62d3a1ea3900003c5171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2617feffb5ceeb2c644679a4de52ecc60797350c883776cfd706b4d7a3c4fca77c93e15ad7243f4fe18c2612728b241f9584a5a7135947b7e8f66dec6f05ae59
|
7
|
+
data.tar.gz: 8bff9d4b572f7bb41de93850651c210e0e59d6e03395e78d10ca777ace00ad31fb85f40c1153fe60062d3ac1a4094b1e6c0e64bef3c44757b3b8f102a776afb6
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" ?><svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M21.928 11.607c-.202-.488-.635-.605-.928-.633V8c0-1.103-.897-2-2-2h-6V4.61c.305-.274.5-.668.5-1.11a1.5 1.5 0 0 0-3 0c0 .442.195.836.5 1.11V6H5c-1.103 0-2 .897-2 2v2.997l-.082.006A1 1 0 0 0 1.99 12v2a1 1 0 0 0 1 1H3v5c0 1.103.897 2 2 2h14c1.103 0 2-.897 2-2v-5a1 1 0 0 0 1-1v-1.938a1.006 1.006 0 0 0-.072-.455zM5 20V8h14l.001 3.996L19 12v2l.001.005.001 5.995H5z"/><ellipse cx="8.5" cy="12" rx="1.5" ry="2"/><ellipse cx="15.5" cy="12" rx="1.5" ry="2"/><path d="M8 16h8v2H8z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" ?><svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2A10.13 10.13 0 0 0 2 12a10 10 0 0 0 4 7.92V20h.1a9.7 9.7 0 0 0 11.8 0h.1v-.08A10 10 0 0 0 22 12 10.13 10.13 0 0 0 12 2zM8.07 18.93A3 3 0 0 1 11 16.57h2a3 3 0 0 1 2.93 2.36 7.75 7.75 0 0 1-7.86 0zm9.54-1.29A5 5 0 0 0 13 14.57h-2a5 5 0 0 0-4.61 3.07A8 8 0 0 1 4 12a8.1 8.1 0 0 1 8-8 8.1 8.1 0 0 1 8 8 8 8 0 0 1-2.39 5.64z"/><path d="M12 6a3.91 3.91 0 0 0-4 4 3.91 3.91 0 0 0 4 4 3.91 3.91 0 0 0 4-4 3.91 3.91 0 0 0-4-4zm0 6a1.91 1.91 0 0 1-2-2 1.91 1.91 0 0 1 2-2 1.91 1.91 0 0 1 2 2 1.91 1.91 0 0 1-2 2z"/></svg>
|
@@ -55,6 +55,25 @@ module RailsPerformance
|
|
55
55
|
db = @datasource.db
|
56
56
|
@data = RailsPerformance::Reports::RecentRequestsReport.new(db).data(params[:from_timei])
|
57
57
|
|
58
|
+
# example
|
59
|
+
# :controller=>"HomeController",
|
60
|
+
# :action=>"index",
|
61
|
+
# :format=>"html",
|
62
|
+
# :status=>"200",
|
63
|
+
# :method=>"GET",
|
64
|
+
# :path=>"/",
|
65
|
+
# :request_id=>"9c9bff5f792a5b3f77cb07fa325f8ddf",
|
66
|
+
# :datetime=>2023-06-24 21:22:46 +0300,
|
67
|
+
# :datetimei=>1687630966,
|
68
|
+
# :duration=>207.225830078125,
|
69
|
+
# :db_runtime=>2.055999994277954,
|
70
|
+
# :view_runtime=>67.8370000096038,
|
71
|
+
# :exception=>nil,
|
72
|
+
# :backtrace=>nil,
|
73
|
+
# :http_referer=>nil,
|
74
|
+
# "email"=>nil,
|
75
|
+
# "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"}]
|
76
|
+
|
58
77
|
respond_to do |page|
|
59
78
|
page.html
|
60
79
|
page.js
|
@@ -92,9 +92,31 @@ module RailsPerformance
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
+
def bot_icon(user_agent)
|
96
|
+
return nil if user_agent.blank?
|
97
|
+
|
98
|
+
# TODO: clean this up
|
99
|
+
# user_agent = "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
|
100
|
+
|
101
|
+
browser = Browser.new(user_agent)
|
102
|
+
|
103
|
+
if browser.bot? || rand(2) == 1
|
104
|
+
content_tag(:span, class: "user-agent-icon", title: browser.bot&.name) do
|
105
|
+
icon("bot")
|
106
|
+
end
|
107
|
+
else
|
108
|
+
content_tag(:span, class: "user-agent-icon") do
|
109
|
+
icon("user")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
95
114
|
def icon(name)
|
96
|
-
|
97
|
-
|
115
|
+
@icons ||= {}
|
116
|
+
@icons[name] ||= begin
|
117
|
+
# https://www.iconfinder.com/iconsets/vivid
|
118
|
+
raw File.read(File.expand_path(File.dirname(__FILE__) + "/../../assets/images/#{name}.svg"))
|
119
|
+
end
|
98
120
|
end
|
99
121
|
|
100
122
|
def insert_css_file(file)
|
@@ -7,6 +7,7 @@
|
|
7
7
|
<% end %>
|
8
8
|
</td>
|
9
9
|
<td><%= format_datetime e[:datetime] %></td>
|
10
|
+
<td><%= bot_icon e["user_agent"] %></td>
|
10
11
|
<td>
|
11
12
|
<% controller_action_info = e[:controller] + '#' + e[:action]%>
|
12
13
|
<%= link_to truncate(controller_action_info, length: 40), rails_performance.rails_performance_summary_path({controller_eq: e[:controller], action_eq: e[:action]}), remote: true, title: controller_action_info %>
|
@@ -7,10 +7,10 @@ module RailsPerformance
|
|
7
7
|
|
8
8
|
def data
|
9
9
|
all = {}
|
10
|
-
stop = Time.at(60 * (Time.now.to_i / 60))
|
10
|
+
stop = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.at(60 * (Time.now.to_i / 60)))
|
11
|
+
offset = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.now).utc_offset
|
11
12
|
current = stop - RailsPerformance.duration
|
12
13
|
@data = []
|
13
|
-
offset = Time.now.utc_offset
|
14
14
|
|
15
15
|
# puts "current: #{current}"
|
16
16
|
# puts "stop: #{stop}"
|
@@ -25,8 +25,8 @@ module RailsPerformance
|
|
25
25
|
# add blank columns
|
26
26
|
while current <= stop
|
27
27
|
views = all[current.strftime(RailsPerformance::FORMAT)] || 0
|
28
|
-
time = RailsPerformance::Reports::
|
29
|
-
@data << [(
|
28
|
+
# time = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(current)
|
29
|
+
@data << [(current.to_i + offset) * 1000, views.round(2)]
|
30
30
|
current += 1.minute
|
31
31
|
end
|
32
32
|
|
@@ -6,12 +6,15 @@ module RailsPerformance
|
|
6
6
|
@group ||= :datetime
|
7
7
|
end
|
8
8
|
|
9
|
+
# RailsPerformance::Reports::ThroughputReport.new(db).data
|
10
|
+
# Time.at(RailsPerformance::Reports::ThroughputReport.new(db).data.last[0] / 1000)
|
11
|
+
|
9
12
|
def data
|
10
13
|
all = {}
|
11
|
-
stop = Time.at(60 * (Time.now.to_i / 60))
|
14
|
+
stop = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.at(60 * (Time.now.to_i / 60)))
|
15
|
+
offset = RailsPerformance::Reports::BaseReport::time_in_app_time_zone(Time.now).utc_offset
|
12
16
|
current = stop - RailsPerformance.duration
|
13
17
|
@data = []
|
14
|
-
offset = Time.now.utc_offset
|
15
18
|
|
16
19
|
# puts "current: #{current}"
|
17
20
|
# puts "stop: #{stop}"
|
@@ -24,8 +27,7 @@ module RailsPerformance
|
|
24
27
|
# add blank columns
|
25
28
|
while current <= stop
|
26
29
|
views = all[current.strftime(RailsPerformance::FORMAT)] || 0
|
27
|
-
|
28
|
-
@data << [(time.to_i + offset) * 1000, views.round(2)]
|
30
|
+
@data << [(current.to_i + offset) * 1000, views.round(2)]
|
29
31
|
current += 1.minute
|
30
32
|
end
|
31
33
|
|
data/lib/rails_performance.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_performance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.alpha4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: browser
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: sqlite3
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +233,7 @@ files:
|
|
219
233
|
- Rakefile
|
220
234
|
- app/assets/config/rails_performance_manifest.js
|
221
235
|
- app/assets/images/activity.svg
|
236
|
+
- app/assets/images/bot.svg
|
222
237
|
- app/assets/images/close.svg
|
223
238
|
- app/assets/images/export.svg
|
224
239
|
- app/assets/images/git.svg
|
@@ -227,6 +242,7 @@ files:
|
|
227
242
|
- app/assets/images/import.svg
|
228
243
|
- app/assets/images/menu.svg
|
229
244
|
- app/assets/images/stat.svg
|
245
|
+
- app/assets/images/user.svg
|
230
246
|
- app/controllers/rails_performance/base_controller.rb
|
231
247
|
- app/controllers/rails_performance/rails_performance_controller.rb
|
232
248
|
- app/helpers/rails_performance/application_helper.rb
|