rails_performance 0.0.1.10 → 0.0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d280495ce11ed162cc6fecc78c795cc3d8c9bf7f27cb3e2b7b4a4394fd6d1a9
4
- data.tar.gz: 14a8dd0d48d334d5b03ccfd8a05a1baa302aee887e3a7b35cb53af952fabc898
3
+ metadata.gz: 939d826d3e398d89839a7bbdd673fbeb1b89bfdbb27ff8b0a096c2bb236096ba
4
+ data.tar.gz: 579db652ed8fe43d1c91284ab07b9f4668f9aa79a87cd40a65f1b290f71d7da1
5
5
  SHA512:
6
- metadata.gz: 799250422e38ebf1f9b9363162a83b0d7bd2c0d7f656c5394d422199e63c0d1ac6fc2873fc4da20ed22254e8149ec1d5303c3f9e24cd75d0c181509476075a67
7
- data.tar.gz: f2df526afb15698f0b0814e4036635e0fb24f54c6869a6f2f4a0532b873a363b1b0b4c02140daaa89ab9e1a7f743a2fed22807ce295bf4b124ddea39950c88a2
6
+ metadata.gz: f15e0fcc4ecd75401140e69f37e2a7fae382392ca5890ba5d5c7fb4194d4888662fc04e2575b6f1f8565a60a0fe42d0635915ea343e70ddae6efb9deec99c863
7
+ data.tar.gz: 538a65badcc5daec51f971be14962b543abd62c718e7bbd1e630304b1e306aae5df47b9be1260108c4a7733352bac91a0b623479e8ef6dfb8a2c62ab4f563fd2
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" ?><svg height="48" id="home" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg"><defs><style>
2
+ .vi-primary {
3
+ fill: #FF6E6E;
4
+ }
5
+
6
+ .vi-primary, .vi-accent {
7
+ stroke: #fff;
8
+ stroke-linecap: round;
9
+ stroke-width: 0;
10
+ fill-rule: evenodd;
11
+ }
12
+
13
+ .vi-accent {
14
+ fill: #0C0058;
15
+ }
16
+ </style></defs><path class="vi-primary" d="M5,24L24,5,43,24H38V40H10V24H5Z"/><path class="vi-accent" d="M19,40V26H29V40H19Z"/></svg>
@@ -12,32 +12,29 @@ class RailsPerformanceController < ActionController::Base
12
12
  end
13
13
 
14
14
  def crashes
15
- @datasource = RP::DataSource.new(prepare_query({status_eq: 500}))
16
- db = @datasource.db
17
- @crash_report = RP::Reports::CrashReport.new(db)
18
- @crash_report_data = @crash_report.data
15
+ @datasource = RP::DataSource.new(prepare_query({status_eq: 500}))
16
+ db = @datasource.db
17
+ @report = RP::Reports::CrashReport.new(db)
18
+ @data = @report.data
19
19
  end
20
20
 
21
21
  def requests
22
- @datasource = RP::DataSource.new(prepare_query)
23
- db = @datasource.db
24
-
25
- @global_report = RP::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :db_runtime_slowest)
26
- @global_report_data = @global_report.data
22
+ @datasource = RP::DataSource.new(prepare_query)
23
+ db = @datasource.db
24
+ @report = RP::Reports::RequestsReport.new(db, group: :controller_action_format, sort: :count)
25
+ @data = @report.data
27
26
  end
28
27
 
29
28
  def breakdown
30
29
  @datasource = RP::DataSource.new(prepare_query)
31
30
  db = @datasource.db
32
-
33
- @breakdown_report = RP::Reports::BreakdownReport.new(db, title: "Breakdown Report")
34
- @breakdown_report_data = @breakdown_report.data
31
+ @report = RP::Reports::BreakdownReport.new(db, title: "Breakdown Report")
32
+ @data = @report.data
35
33
  end
36
34
 
37
35
  def recent
38
36
  @datasource = RP::DataSource.new(prepare_query)
39
37
  db = @datasource.db
40
-
41
38
  @report = RP::Reports::RecentRequestsReport.new(db)
42
39
  @data = @report.data
43
40
  end
@@ -6,6 +6,25 @@ module RailsPerformanceHelper
6
6
  value.nan? ? nil : value.round(2)
7
7
  end
8
8
 
9
+ def ms(value)
10
+ result = round_it(value)
11
+ result ? "#{result} ms" : '-'
12
+ end
13
+
14
+ def short_path(path, length: 60)
15
+ tag.span title: path do
16
+ truncate(path, length: length)
17
+ end
18
+ end
19
+
20
+ def link_to_path(e)
21
+ if e[:method] == 'GET'
22
+ link_to short_path(e[:path]), e[:path], target: '_blank'
23
+ else
24
+ short_path(e[:path])
25
+ end
26
+ end
27
+
9
28
  def statistics_link(title, report, group)
10
29
  options = case report.group
11
30
  when :controller_action_format
@@ -41,9 +60,9 @@ module RailsPerformanceHelper
41
60
  end
42
61
  end
43
62
 
44
- def stats_icon
63
+ def icon(name)
45
64
  # https://www.iconfinder.com/iconsets/vivid
46
- raw File.read(File.expand_path(File.dirname(__FILE__) + "/../assets/images/stat.svg"))
65
+ raw File.read(File.expand_path(File.dirname(__FILE__) + "/../assets/images/#{name}.svg"))
47
66
  end
48
67
 
49
68
  def insert_css_file(file)
@@ -1,8 +1,8 @@
1
- <title><%= @breakdown_report.title %></title>
1
+ <title><%= @report.title %></title>
2
2
 
3
3
  <div class="card">
4
4
  <div class="card-content">
5
- <h2 class="subtitle"><%= @breakdown_report.title %></h2>
5
+ <h2 class="subtitle"><%= @report.title %></h2>
6
6
  <table class="table is-fullwidth is-hoverable is-narrow">
7
7
  <thead>
8
8
  <tr>
@@ -18,23 +18,17 @@
18
18
  </tr>
19
19
  </thead>
20
20
  <tbody>
21
- <% @breakdown_report_data.each do |e| %>
21
+ <% @data.each do |e| %>
22
22
  <tr>
23
23
  <td><%= l e[:datetime], format: :short %></td>
24
24
  <td><%= e[:controller] + '#' + e[:action] %></td>
25
25
  <td><%= e[:method] %></td>
26
- <td>
27
- <% if e[:method] == 'GET' %>
28
- <%= link_to e[:path], e[:path], target: '_blank' %>
29
- <% else %>
30
- <%= e[:path] %>
31
- <% end %>
32
- </td>
26
+ <td><%= link_to_path(e) %></td>
33
27
  <td><%= e[:format] %></td>
34
28
  <td><%= status_tag e[:status] %></td>
35
- <td><%= round_it e[:duration] %> ms</td>
36
- <td><%= round_it e[:view_runtime] %> ms</td>
37
- <td><%= round_it e[:db_runtime] %> ms</td>
29
+ <td><%= ms e[:duration] %></td>
30
+ <td><%= ms e[:view_runtime] %></td>
31
+ <td><%= ms e[:db_runtime] %></td>
38
32
  </tr>
39
33
  <% end %>
40
34
  </tbody>
@@ -6,8 +6,8 @@
6
6
  <tr>
7
7
  <th>Datetime</th>
8
8
  <th>Controller#Action</th>
9
- <th>Format</th>
10
9
  <th>Method</th>
10
+ <th>Format</th>
11
11
  <th>Path</th>
12
12
  <th>Status</th>
13
13
  <th>Duration</th>
@@ -16,23 +16,17 @@
16
16
  </tr>
17
17
  </thead>
18
18
  <tbody>
19
- <% @crash_report_data.each do |e| %>
19
+ <% @data.each do |e| %>
20
20
  <tr>
21
- <td><%= l e[:datetime], format: :short %></td>
21
+ <td><%= format_datetime e[:datetime] %></td>
22
22
  <td><%= e[:controller] + '#' + e[:action] %></td>
23
- <td><%= e[:format] %></td>
24
23
  <td><%= e[:method] %></td>
25
- <td>
26
- <% if e[:method] == 'GET' %>
27
- <%= link_to e[:path], e[:path], target: '_blank' %>
28
- <% else %>
29
- <%= e[:path] %>
30
- <% end %>
31
- </td>
24
+ <td><%= e[:format] %></td>
25
+ <td><%= link_to_path(e) %></td>
32
26
  <td><%= status_tag e[:status] %></td>
33
- <td><%= round_it e[:duration] %> ms</td>
34
- <td><%= round_it e[:view_runtime] %> ms</td>
35
- <td><%= round_it e[:db_runtime] %> ms</td>
27
+ <td><%= ms e[:duration] %></td>
28
+ <td><%= ms e[:view_runtime] %></td>
29
+ <td><%= ms e[:db_runtime] %></td>
36
30
  </tr>
37
31
  <% end %>
38
32
  </tbody>
@@ -8,8 +8,8 @@
8
8
  <tr>
9
9
  <th>Datetime</th>
10
10
  <th>Controller#Action</th>
11
- <th>Format</th>
12
11
  <th>Method</th>
12
+ <th>Format</th>
13
13
  <th>Path</th>
14
14
  <th>Status</th>
15
15
  <th>Duration</th>
@@ -22,19 +22,13 @@
22
22
  <tr>
23
23
  <td><%= format_datetime e[:datetime] %></td>
24
24
  <td><%= e[:controller] + '#' + e[:action] %></td>
25
- <td><%= e[:format] %></td>
26
25
  <td><%= e[:method] %></td>
27
- <td>
28
- <% if e[:method] == 'GET' %>
29
- <%= link_to e[:path], e[:path], target: '_blank' %>
30
- <% else %>
31
- <%= e[:path] %>
32
- <% end %>
33
- </td>
26
+ <td><%= e[:format] %></td>
27
+ <td><%= link_to_path(e) %></td>
34
28
  <td><%= status_tag e[:status] %></td>
35
- <td><%= round_it e[:duration] %> ms</td>
36
- <td><%= round_it e[:view_runtime] %> ms</td>
37
- <td><%= round_it e[:db_runtime] %> ms</td>
29
+ <td><%= ms e[:duration] %></td>
30
+ <td><%= ms e[:view_runtime] %></td>
31
+ <td><%= ms e[:db_runtime] %></td>
38
32
  </tr>
39
33
  <% end %>
40
34
  </tbody>
@@ -21,24 +21,24 @@
21
21
  </tr>
22
22
  </thead>
23
23
  <tbody>
24
- <% @global_report_data.each do |e| %>
24
+ <% @data.each do |e| %>
25
25
  <% groups = e[:group].split("|") %>
26
26
  <% c, a = groups[0].split("#") %>
27
27
  <tr>
28
28
  <td>
29
- <%= statistics_link groups[0], @global_report, e[:group] %>
29
+ <%= statistics_link groups[0], @report, e[:group] %>
30
30
  <%= link_to rails_performance.rails_performance_breakdown_path(controller_eq: c, action_eq: a), class: 'stats_icon', target: '_blank' do %>
31
- <%= raw(stats_icon) %>
31
+ <%= icon("stat") %>
32
32
  <% end %>
33
33
  </td>
34
- <td><%= statistics_link groups[1]&.upcase, @global_report, e[:group] %></td>
34
+ <td><%= statistics_link groups[1]&.upcase, @report, e[:group] %></td>
35
35
  <td><%= e[:count] %></td>
36
- <td><%= round_it e[:duration_average] %> ms</td>
37
- <td><%= round_it e[:view_runtime_average] %> ms</td>
38
- <td><%= round_it e[:db_runtime_average] %> ms</td>
39
- <td><%= round_it e[:duration_slowest] %> ms</td>
40
- <td><%= round_it e[:view_runtime_slowest] %> ms</td>
41
- <td><%= round_it e[:db_runtime_slowest] %> ms</td>
36
+ <td><%= ms e[:duration_average] %></td>
37
+ <td><%= ms e[:view_runtime_average] %></td>
38
+ <td><%= ms e[:db_runtime_average] %></td>
39
+ <td><%= ms e[:duration_slowest] %></td>
40
+ <td><%= ms e[:view_runtime_slowest] %></td>
41
+ <td><%= ms e[:db_runtime_slowest] %></td>
42
42
  </tr>
43
43
  <% end %>
44
44
  </tbody>
@@ -26,6 +26,9 @@
26
26
  <div class="buttons">
27
27
  <%#= link_to 'Export to CSV', '#', target: '_blank', class: "button is-primary" %>
28
28
  <%= link_to 'Documentation', 'https://github.com/igorkasyanchuk/rails_performance', target: '_blank', class: "button is-light" %>
29
+ <%= link_to '/', target: '_blank', class: "button is-light home_icon" do %>
30
+ <%= icon('home') %>
31
+ <% end %>
29
32
  </div>
30
33
  </div>
31
34
  </div>
@@ -3,6 +3,11 @@
3
3
  height: 16px;
4
4
  }
5
5
 
6
+ .home_icon svg {
7
+ width: 24px;
8
+ height: 24px;
9
+ }
10
+
6
11
  .chart {
7
12
  height: 255px;
8
13
  }
@@ -20,7 +20,7 @@ module RailsPerformance
20
20
  view_runtime_slowest: view_runtimes.max,
21
21
  db_runtime_slowest: db_runtimes.max,
22
22
  }
23
- end.sort{|a, b| b[sort] <=> a[sort]}
23
+ end.sort_by{|e| -e[sort].to_f} # to_f because could ne NaN or nil
24
24
  end
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module RailsPerformance
2
- VERSION = '0.0.1.10'
2
+ VERSION = '0.0.1.11'
3
3
  end
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: 0.0.1.10
4
+ version: 0.0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk
@@ -91,6 +91,7 @@ files:
91
91
  - README.md
92
92
  - Rakefile
93
93
  - app/assets/config/rails_performance_manifest.js
94
+ - app/assets/images/home.svg
94
95
  - app/assets/images/stat.svg
95
96
  - app/controllers/rails_performance_controller.rb
96
97
  - app/helpers/rails_performance_helper.rb