rails_performance 1.2.0.alpha3 → 1.2.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4cc5606eeacc1d036f322a9eda07cea2d2151c23ad96052f2e7a695ea288e5a
4
- data.tar.gz: 51fe7e76287eb361e0d2135039f4f95c03f559ca575bae8883b1a94c107762e2
3
+ metadata.gz: 71e33d8156df40c792e33f03eae39a06c12f1622aa2c8071291c4e81c803d3ac
4
+ data.tar.gz: 288c78335fec92abede6d72f82b841fd128ff079baad62d3a1ea3900003c5171
5
5
  SHA512:
6
- metadata.gz: fc80d1c5713b87b6338778086bc6b4180f36bfd9d38b96753bf92e733f985fa9101ea53c8a426a0cf41c1916dc83266d7f53868b2ceaf6aa4c7c7be11f3ab158
7
- data.tar.gz: 8a54a10c63673d143fe07cfddf03db2000d6f957b3d913edfebf5f0c06f598c5808732dedbb0e3b37e4b280cd00f21b5ba21dbe36248103c5f930015870e81f9
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
- # https://www.iconfinder.com/iconsets/vivid
97
- raw File.read(File.expand_path(File.dirname(__FILE__) + "/../../assets/images/#{name}.svg"))
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 %>
@@ -19,6 +19,7 @@
19
19
  <tr>
20
20
  <th data-sort="string"></th>
21
21
  <th data-sort="string">Datetime</th>
22
+ <th></th>
22
23
  <th data-sort="string">Controller#action</th>
23
24
  <th data-sort="string">Method</th>
24
25
  <th data-sort="string">Format</th>
@@ -13,6 +13,7 @@
13
13
  <tr>
14
14
  <th data-sort="string"></th>
15
15
  <th data-sort="string">Datetime</th>
16
+ <th></th>
16
17
  <th data-sort="string">Controller#action</th>
17
18
  <th data-sort="string">Method</th>
18
19
  <th data-sort="string">Format</th>
@@ -56,6 +56,11 @@
56
56
  height: 24px;
57
57
  }
58
58
 
59
+ .user-agent-icon svg {
60
+ width: 12px;
61
+ height: 12px;
62
+ }
63
+
59
64
  .chart {
60
65
  height: 245px;
61
66
  }
@@ -1,4 +1,4 @@
1
1
  module RailsPerformance
2
- VERSION = '1.2.0.alpha3'
2
+ VERSION = '1.2.0.alpha4'
3
3
  SCHEMA = '1.0.1'
4
4
  end
@@ -1,5 +1,6 @@
1
1
  require "redis"
2
2
  require "redis-namespace"
3
+ require "browser"
3
4
  require_relative "./rails_performance/version.rb"
4
5
  require_relative "rails_performance/rails/query_builder.rb"
5
6
  require_relative "rails_performance/rails/middleware.rb"
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.alpha3
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