active-record-query-count 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +126 -0
- data/bin/setup +8 -0
- data/images/bar_chart.png +0 -0
- data/images/html.png +0 -0
- data/images/terminal.png +0 -0
- data/lib/active_record_query_count/compare/comparator.rb +33 -0
- data/lib/active_record_query_count/configuration.rb +12 -0
- data/lib/active_record_query_count/middleware.rb +37 -0
- data/lib/active_record_query_count/printer/base.rb +42 -0
- data/lib/active_record_query_count/printer/console.rb +30 -0
- data/lib/active_record_query_count/printer/html.rb +68 -0
- data/lib/active_record_query_count/printer/html_compare.rb +64 -0
- data/lib/active_record_query_count/printer/templates/bar_chart.js +153 -0
- data/lib/active_record_query_count/printer/templates/comparing.html.erb +66 -0
- data/lib/active_record_query_count/printer/templates/style.css +41 -0
- data/lib/active_record_query_count/printer/templates/template.html.erb +9 -0
- data/lib/active_record_query_count/printer/templates/template_base_query_counter.html.erb +51 -0
- data/lib/active_record_query_count/printer/templates/template_for_inject.html.erb +64 -0
- data/lib/active_record_query_count/recording/base.rb +28 -0
- data/lib/active_record_query_count/recording/tracker.rb +40 -0
- data/lib/active_record_query_count/version.rb +5 -0
- data/lib/active_record_query_count.rb +37 -0
- data/scripts_for_testing/example_script_optimize.yaml +217 -0
- data/scripts_for_testing/example_script_unoptimize.yaml +142 -0
- data/scripts_for_testing/script_compare_html.rb +16 -0
- data/scripts_for_testing/script_printer_html.rb +8 -0
- data/scripts_for_testing/scripts_console.rb.rb +8 -0
- metadata +266 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
#query_counter_report_gem {
|
2
|
+
font-family: Arial, sans-serif;
|
3
|
+
table {
|
4
|
+
width: 100%;
|
5
|
+
border-collapse: collapse;
|
6
|
+
margin-top: 20px;
|
7
|
+
|
8
|
+
height: 100%;
|
9
|
+
overflow:auto;
|
10
|
+
display: block; /* Ensure the table behaves as a block element */
|
11
|
+
box-sizing: border-box;
|
12
|
+
}
|
13
|
+
th, td {
|
14
|
+
border: 1px solid #ddd;
|
15
|
+
padding: 8px;
|
16
|
+
}
|
17
|
+
th {
|
18
|
+
background-color: #f2f2f2;
|
19
|
+
}
|
20
|
+
tr:nth-child(even) {
|
21
|
+
background-color: #f9f9f9;
|
22
|
+
}
|
23
|
+
.sub-row {
|
24
|
+
background-color: #f9f9f9;
|
25
|
+
}
|
26
|
+
.center-container {
|
27
|
+
text-align: center;
|
28
|
+
width: 100%;
|
29
|
+
height: 500px;
|
30
|
+
}
|
31
|
+
|
32
|
+
#queryCountChart {
|
33
|
+
display: none;
|
34
|
+
margin: 0 auto;
|
35
|
+
width: 1200px;
|
36
|
+
height: 500px;
|
37
|
+
}
|
38
|
+
#queryTable {
|
39
|
+
display: table;
|
40
|
+
}
|
41
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<script>
|
2
|
+
<%= js_content %>
|
3
|
+
</script>
|
4
|
+
<style>
|
5
|
+
<%= css_content %>
|
6
|
+
</style>
|
7
|
+
<div id='query_counter_report_gem'>
|
8
|
+
<h2>Query Counter Report</h2>
|
9
|
+
<p>Total query count on process: <%= total_query_count %></p>
|
10
|
+
<p>The table will show only tables with more than <%= ::ActiveRecordQueryCount::Configuration.ignore_table_count %> queries</p>
|
11
|
+
<p>Only the top <%= ::ActiveRecordQueryCount::Configuration.max_locations_per_table %> locations with the most occurrences will be shown.</p>
|
12
|
+
<button id="toggleButton" onclick="toggleView()">Show Chart View</button>
|
13
|
+
<button id="toggleColumnButton" onclick="toggleColumnContent()">Show SQL</button>
|
14
|
+
|
15
|
+
<div class="center-container">
|
16
|
+
<canvas id="queryCountChart"></canvas>
|
17
|
+
</div>
|
18
|
+
<table id="queryTable">
|
19
|
+
<tr>
|
20
|
+
<th>Table</th>
|
21
|
+
<th>Total Query Count</th>
|
22
|
+
<th id="columnHeader">File Path</th>
|
23
|
+
<th>Method</th>
|
24
|
+
<th>Location Count</th>
|
25
|
+
</tr>
|
26
|
+
<% filter_data(data).each do |table, info| %>
|
27
|
+
<tr>
|
28
|
+
<td rowspan="<%= info[:location].size + 1 %>"><%= table %></td>
|
29
|
+
<td rowspan="<%= info[:location].size + 1 %>"><%= info[:count] %></td>
|
30
|
+
</tr>
|
31
|
+
<% info[:location].each do |loc, detail| %>
|
32
|
+
<tr class="sub-row">
|
33
|
+
<% match = loc&.match(/^(?<file_path>.*):in.*`(?<method>.*)'$/) %>
|
34
|
+
<% file_path = match ? match[:file_path] : loc %>
|
35
|
+
<% method = match ? match[:method] : nil %>
|
36
|
+
<td class="toggle-content">
|
37
|
+
<span class="filepath"><%= file_path %></span>
|
38
|
+
<span class="sql" style="display: none;"><%= detail[:sql].gsub('"', '') %></span>
|
39
|
+
</td>
|
40
|
+
<td class="method-column"><%= method %></td>
|
41
|
+
<td><%= detail[:count] %></td>
|
42
|
+
</tr>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
</table>
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
47
|
+
<script>
|
48
|
+
const chartData = <%= chart_data.to_json %>;
|
49
|
+
initializeChart(chartData);
|
50
|
+
</script>
|
51
|
+
</div>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
<style>
|
2
|
+
#query-modal-button {
|
3
|
+
position: fixed;
|
4
|
+
top: 10px;
|
5
|
+
left: 10px;
|
6
|
+
z-index: 1000000;
|
7
|
+
background-color: #007bff;
|
8
|
+
color: white;
|
9
|
+
border: none;
|
10
|
+
padding: 10px;
|
11
|
+
cursor: pointer;
|
12
|
+
}
|
13
|
+
|
14
|
+
#query-modal-button:hover {
|
15
|
+
background-color: #0056b3;
|
16
|
+
}
|
17
|
+
|
18
|
+
#modal-close-button {
|
19
|
+
background-color: #d9534f;
|
20
|
+
color: white;
|
21
|
+
border: none;
|
22
|
+
padding: 5px;
|
23
|
+
cursor: pointer;
|
24
|
+
}
|
25
|
+
|
26
|
+
#modal-close-button:hover {
|
27
|
+
background-color: #c9302c;
|
28
|
+
}
|
29
|
+
|
30
|
+
#modal-content-query-count {
|
31
|
+
display: none;
|
32
|
+
position: fixed;
|
33
|
+
top: 10%;
|
34
|
+
left: 10%;
|
35
|
+
width: 80%;
|
36
|
+
height: 700px;
|
37
|
+
max-height: 80%;
|
38
|
+
background-color: white;
|
39
|
+
border: 1px solid #ccc;
|
40
|
+
padding: 10px;
|
41
|
+
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
|
42
|
+
z-index: 10000000;
|
43
|
+
overflow: auto;
|
44
|
+
}
|
45
|
+
|
46
|
+
<%= css_content %>
|
47
|
+
</style>
|
48
|
+
<script>
|
49
|
+
function toggleQueryModal() {
|
50
|
+
var modal = document.getElementById('modal-content-query-count');
|
51
|
+
if (modal.style.display === 'none' || modal.style.display === '') {
|
52
|
+
modal.style.display = 'block';
|
53
|
+
} else {
|
54
|
+
modal.style.display = 'none';
|
55
|
+
}
|
56
|
+
}
|
57
|
+
</script>
|
58
|
+
<div id="query-modal-button">
|
59
|
+
<button id="query-modal-button" onclick="toggleQueryModal()">Toggle Query Counter</button>
|
60
|
+
</div>
|
61
|
+
<div id="modal-content-query-count">
|
62
|
+
<button id="modal-close-button" onclick="toggleQueryModal()">Close</button>
|
63
|
+
<%= render_query_counter_base_div %>
|
64
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ActiveRecordQueryCount
|
2
|
+
module Recording
|
3
|
+
module Base
|
4
|
+
def start_with_block(printer: :console)
|
5
|
+
raise 'Block not given' unless block_given?
|
6
|
+
|
7
|
+
start_recording
|
8
|
+
yield
|
9
|
+
end_recording(printer: printer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_recording
|
13
|
+
tracker.reset_query_count
|
14
|
+
tracker.subscribe
|
15
|
+
end
|
16
|
+
|
17
|
+
def end_recording(printer: :console)
|
18
|
+
tracker.unsubscribe
|
19
|
+
case printer
|
20
|
+
when :html
|
21
|
+
Printer::Html.new(data: tracker.active_record_query_tracker).print
|
22
|
+
when :console
|
23
|
+
Printer::Console.new(data: tracker.active_record_query_tracker).print
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module ActiveRecordQueryCount
|
2
|
+
class Tracker
|
3
|
+
REGEX_TABLE_SQL = /FROM\s+"(?<table>[^"]+)"/
|
4
|
+
attr_accessor :active_record_query_tracker, :subscription
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
reset_query_count
|
8
|
+
end
|
9
|
+
|
10
|
+
# This assums that in the same location of the code it will always be the same sql query
|
11
|
+
def reset_query_count
|
12
|
+
@active_record_query_tracker = Hash.new do |hash, key|
|
13
|
+
hash[key] = { count: 0, location: Hash.new do |loc_hash, loc_key|
|
14
|
+
loc_hash[loc_key] = { count: 0, sql: nil }
|
15
|
+
end }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def subscribe
|
20
|
+
return unless subscription.nil?
|
21
|
+
|
22
|
+
@subscription = ActiveSupport::Notifications.subscribe('sql.active_record') do |_a, _b, _c, _d, payload|
|
23
|
+
caller_from_sql = caller
|
24
|
+
sql = payload[:sql]
|
25
|
+
match = sql.match(REGEX_TABLE_SQL)
|
26
|
+
if match.present? && match[:table]
|
27
|
+
actual_location = Rails.backtrace_cleaner.clean(caller_from_sql).first
|
28
|
+
active_record_query_tracker[match[:table]][:count] += 1
|
29
|
+
active_record_query_tracker[match[:table]][:location][actual_location][:count] += 1
|
30
|
+
active_record_query_tracker[match[:table]][:location][actual_location][:sql] = sql
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def unsubscribe
|
36
|
+
ActiveSupport::Notifications.unsubscribe(@subscription)
|
37
|
+
@subscription = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'active_support/notifications'
|
2
|
+
require_relative 'active_record_query_count/version'
|
3
|
+
require_relative 'active_record_query_count/configuration'
|
4
|
+
require_relative 'active_record_query_count/printer/base'
|
5
|
+
require_relative 'active_record_query_count/printer/console'
|
6
|
+
require_relative 'active_record_query_count/printer/html'
|
7
|
+
require_relative 'active_record_query_count/recording/base'
|
8
|
+
require_relative 'active_record_query_count/recording/tracker'
|
9
|
+
require_relative 'active_record_query_count/compare/comparator'
|
10
|
+
require_relative 'active_record_query_count/middleware'
|
11
|
+
require_relative 'active_record_query_count/printer/html_compare'
|
12
|
+
|
13
|
+
module ActiveRecordQueryCount
|
14
|
+
extend Recording::Base
|
15
|
+
if defined?(Rails::Railtie)
|
16
|
+
class QueryTrackerRailtie < Rails::Railtie
|
17
|
+
initializer 'active_record_query_count.configure_rails_initialization' do |app|
|
18
|
+
app.middleware.use Middleware
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def configure
|
25
|
+
yield(Configuration)
|
26
|
+
end
|
27
|
+
|
28
|
+
def tracker
|
29
|
+
Thread.current[:query_counter_data] ||= Tracker.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def compare
|
33
|
+
comparator = Compare::Comparator.new
|
34
|
+
yield(comparator)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
---
|
2
|
+
east_caronberg:
|
3
|
+
:count: 1
|
4
|
+
:location:
|
5
|
+
app/models/east_caronberg.rb:47:in `building_number':
|
6
|
+
:count: 1
|
7
|
+
:sql: SELECT * FROM east_caronberg
|
8
|
+
jerdeburgh:
|
9
|
+
:count: 1
|
10
|
+
:location:
|
11
|
+
app/models/jerdeburgh.rb:13:in `longitude':
|
12
|
+
:count: 1
|
13
|
+
:sql: SELECT * FROM jerdeburgh
|
14
|
+
new_cyrus:
|
15
|
+
:count: 1
|
16
|
+
:location:
|
17
|
+
app/models/new_cyrus.rb:41:in `state':
|
18
|
+
:count: 1
|
19
|
+
:sql: SELECT * FROM new_cyrus
|
20
|
+
lake_tyson:
|
21
|
+
:count: 3
|
22
|
+
:location:
|
23
|
+
app/models/lake_tyson.rb:99:in `state':
|
24
|
+
:count: 2
|
25
|
+
:sql: SELECT * FROM lake_tyson
|
26
|
+
app/models/lake_tyson.rb:66:in `zip_code':
|
27
|
+
:count: 1
|
28
|
+
:sql: SELECT * FROM lake_tyson
|
29
|
+
new_damionview:
|
30
|
+
:count: 5
|
31
|
+
:location:
|
32
|
+
app/models/new_damionview.rb:91:in `zip_code':
|
33
|
+
:count: 1
|
34
|
+
:sql: SELECT * FROM new_damionview
|
35
|
+
app/models/new_damionview.rb:79:in `street_name':
|
36
|
+
:count: 1
|
37
|
+
:sql: SELECT * FROM new_damionview
|
38
|
+
app/models/new_damionview.rb:74:in `street_name':
|
39
|
+
:count: 3
|
40
|
+
:sql: SELECT * FROM new_damionview
|
41
|
+
jermaineshire:
|
42
|
+
:count: 18
|
43
|
+
:location:
|
44
|
+
app/models/jermaineshire.rb:12:in `city':
|
45
|
+
:count: 1
|
46
|
+
:sql: SELECT * FROM jermaineshire
|
47
|
+
app/models/jermaineshire.rb:99:in `street_name':
|
48
|
+
:count: 17
|
49
|
+
:sql: SELECT * FROM jermaineshire
|
50
|
+
kilbacktown:
|
51
|
+
:count: 1
|
52
|
+
:location:
|
53
|
+
app/models/kilbacktown.rb:45:in `latitude':
|
54
|
+
:count: 1
|
55
|
+
:sql: SELECT * FROM kilbacktown
|
56
|
+
south_brock:
|
57
|
+
:count: 3
|
58
|
+
:location:
|
59
|
+
app/models/south_brock.rb:62:in `building_number':
|
60
|
+
:count: 1
|
61
|
+
:sql: SELECT * FROM south_brock
|
62
|
+
app/models/south_brock.rb:63:in `city':
|
63
|
+
:count: 2
|
64
|
+
:sql: SELECT * FROM south_brock
|
65
|
+
lake_arlie:
|
66
|
+
:count: 6
|
67
|
+
:location:
|
68
|
+
app/models/lake_arlie.rb:87:in `longitude':
|
69
|
+
:count: 1
|
70
|
+
:sql: SELECT * FROM lake_arlie
|
71
|
+
app/models/lake_arlie.rb:74:in `city':
|
72
|
+
:count: 1
|
73
|
+
:sql: SELECT * FROM lake_arlie
|
74
|
+
app/models/lake_arlie.rb:54:in `street_name':
|
75
|
+
:count: 2
|
76
|
+
:sql: SELECT * FROM lake_arlie
|
77
|
+
app/models/lake_arlie.rb:43:in `latitude':
|
78
|
+
:count: 2
|
79
|
+
:sql: SELECT * FROM lake_arlie
|
80
|
+
south_mauricio:
|
81
|
+
:count: 12
|
82
|
+
:location:
|
83
|
+
app/models/south_mauricio.rb:83:in `city':
|
84
|
+
:count: 4
|
85
|
+
:sql: SELECT * FROM south_mauricio
|
86
|
+
app/models/south_mauricio.rb:59:in `state':
|
87
|
+
:count: 4
|
88
|
+
:sql: SELECT * FROM south_mauricio
|
89
|
+
app/models/south_mauricio.rb:60:in `longitude':
|
90
|
+
:count: 4
|
91
|
+
:sql: SELECT * FROM south_mauricio
|
92
|
+
east_curtfort:
|
93
|
+
:count: 8
|
94
|
+
:location:
|
95
|
+
app/models/east_curtfort.rb:37:in `longitude':
|
96
|
+
:count: 1
|
97
|
+
:sql: SELECT * FROM east_curtfort
|
98
|
+
app/models/east_curtfort.rb:97:in `city':
|
99
|
+
:count: 4
|
100
|
+
:sql: SELECT * FROM east_curtfort
|
101
|
+
app/models/east_curtfort.rb:56:in `city':
|
102
|
+
:count: 3
|
103
|
+
:sql: SELECT * FROM east_curtfort
|
104
|
+
hudsonborough:
|
105
|
+
:count: 60
|
106
|
+
:location:
|
107
|
+
app/models/hudsonborough.rb:65:in `latitude':
|
108
|
+
:count: 4
|
109
|
+
:sql: SELECT * FROM hudsonborough
|
110
|
+
app/models/hudsonborough.rb:19:in `longitude':
|
111
|
+
:count: 4
|
112
|
+
:sql: SELECT * FROM hudsonborough
|
113
|
+
app/models/hudsonborough.rb:26:in `latitude':
|
114
|
+
:count: 26
|
115
|
+
:sql: SELECT * FROM hudsonborough
|
116
|
+
app/models/hudsonborough.rb:39:in `zip_code':
|
117
|
+
:count: 26
|
118
|
+
:sql: SELECT * FROM hudsonborough
|
119
|
+
port_richmouth:
|
120
|
+
:count: 4
|
121
|
+
:location:
|
122
|
+
app/models/port_richmouth.rb:86:in `street_name':
|
123
|
+
:count: 4
|
124
|
+
:sql: SELECT * FROM port_richmouth
|
125
|
+
north_felica:
|
126
|
+
:count: 4
|
127
|
+
:location:
|
128
|
+
app/models/north_felica.rb:54:in `building_number':
|
129
|
+
:count: 4
|
130
|
+
:sql: SELECT * FROM north_felica
|
131
|
+
east_arnoldfurt:
|
132
|
+
:count: 8
|
133
|
+
:location:
|
134
|
+
app/models/east_arnoldfurt.rb:13:in `building_number':
|
135
|
+
:count: 4
|
136
|
+
:sql: SELECT * FROM east_arnoldfurt
|
137
|
+
app/models/east_arnoldfurt.rb:87:in `latitude':
|
138
|
+
:count: 4
|
139
|
+
:sql: SELECT * FROM east_arnoldfurt
|
140
|
+
new_nga:
|
141
|
+
:count: 13
|
142
|
+
:location:
|
143
|
+
app/models/new_nga.rb:74:in `zip_code':
|
144
|
+
:count: 4
|
145
|
+
:sql: SELECT * FROM new_nga
|
146
|
+
app/models/new_nga.rb:18:in `country':
|
147
|
+
:count: 4
|
148
|
+
:sql: SELECT * FROM new_nga
|
149
|
+
app/models/new_nga.rb:58:in `street_name':
|
150
|
+
:count: 1
|
151
|
+
:sql: SELECT * FROM new_nga
|
152
|
+
app/models/new_nga.rb:43:in `building_number':
|
153
|
+
:count: 1
|
154
|
+
:sql: SELECT * FROM new_nga
|
155
|
+
app/models/new_nga.rb:85:in `longitude':
|
156
|
+
:count: 3
|
157
|
+
:sql: SELECT * FROM new_nga
|
158
|
+
port_allenastad:
|
159
|
+
:count: 4
|
160
|
+
:location:
|
161
|
+
app/models/port_allenastad.rb:95:in `longitude':
|
162
|
+
:count: 4
|
163
|
+
:sql: SELECT * FROM port_allenastad
|
164
|
+
north_tad:
|
165
|
+
:count: 4
|
166
|
+
:location:
|
167
|
+
app/models/north_tad.rb:64:in `street_name':
|
168
|
+
:count: 4
|
169
|
+
:sql: SELECT * FROM north_tad
|
170
|
+
vanmouth:
|
171
|
+
:count: 4
|
172
|
+
:location:
|
173
|
+
app/models/vanmouth.rb:47:in `longitude':
|
174
|
+
:count: 4
|
175
|
+
:sql: SELECT * FROM vanmouth
|
176
|
+
windlerport:
|
177
|
+
:count: 4
|
178
|
+
:location:
|
179
|
+
app/models/windlerport.rb:70:in `state':
|
180
|
+
:count: 4
|
181
|
+
:sql: SELECT * FROM windlerport
|
182
|
+
framiport:
|
183
|
+
:count: 1
|
184
|
+
:location:
|
185
|
+
app/models/framiport.rb:97:in `zip_code':
|
186
|
+
:count: 1
|
187
|
+
:sql: SELECT * FROM framiport
|
188
|
+
wittingborough:
|
189
|
+
:count: 1
|
190
|
+
:location:
|
191
|
+
app/models/wittingborough.rb:47:in `latitude':
|
192
|
+
:count: 1
|
193
|
+
:sql: SELECT * FROM wittingborough
|
194
|
+
burtchester:
|
195
|
+
:count: 1
|
196
|
+
:location:
|
197
|
+
app/models/burtchester.rb:97:in `latitude':
|
198
|
+
:count: 1
|
199
|
+
:sql: SELECT * FROM burtchester
|
200
|
+
renatotown:
|
201
|
+
:count: 1
|
202
|
+
:location:
|
203
|
+
app/models/renatotown.rb:57:in `state':
|
204
|
+
:count: 1
|
205
|
+
:sql: SELECT * FROM renatotown
|
206
|
+
bogisichbury:
|
207
|
+
:count: 1
|
208
|
+
:location:
|
209
|
+
app/models/bogisichbury.rb:94:in `longitude':
|
210
|
+
:count: 1
|
211
|
+
:sql: SELECT * FROM bogisichbury
|
212
|
+
east_clemmiebury:
|
213
|
+
:count: 1
|
214
|
+
:location:
|
215
|
+
app/models/east_clemmiebury.rb:71:in `street_name':
|
216
|
+
:count: 1
|
217
|
+
:sql: SELECT * FROM east_clemmiebury
|
@@ -0,0 +1,142 @@
|
|
1
|
+
---
|
2
|
+
east_caronberg:
|
3
|
+
:count: 1
|
4
|
+
:location:
|
5
|
+
app/models/east_caronberg.rb:82:in `zip_code':
|
6
|
+
:count: 1
|
7
|
+
:sql: SELECT * FROM east_caronberg
|
8
|
+
jerdeburgh:
|
9
|
+
:count: 1
|
10
|
+
:location:
|
11
|
+
app/models/jerdeburgh.rb:12:in `latitude':
|
12
|
+
:count: 1
|
13
|
+
:sql: SELECT * FROM jerdeburgh
|
14
|
+
south_brock:
|
15
|
+
:count: 2
|
16
|
+
:location:
|
17
|
+
app/models/south_brock.rb:51:in `latitude':
|
18
|
+
:count: 2
|
19
|
+
:sql: SELECT * FROM south_brock
|
20
|
+
lake_arlie:
|
21
|
+
:count: 5
|
22
|
+
:location:
|
23
|
+
app/models/lake_arlie.rb:31:in `city':
|
24
|
+
:count: 1
|
25
|
+
:sql: SELECT * FROM lake_arlie
|
26
|
+
app/models/lake_arlie.rb:90:in `latitude':
|
27
|
+
:count: 2
|
28
|
+
:sql: SELECT * FROM lake_arlie
|
29
|
+
app/models/lake_arlie.rb:60:in `street_name':
|
30
|
+
:count: 2
|
31
|
+
:sql: SELECT * FROM lake_arlie
|
32
|
+
south_mauricio:
|
33
|
+
:count: 2096
|
34
|
+
:location:
|
35
|
+
app/models/south_mauricio.rb:32:in `city':
|
36
|
+
:count: 4
|
37
|
+
:sql: SELECT * FROM south_mauricio
|
38
|
+
app/models/south_mauricio.rb:46:in `latitude':
|
39
|
+
:count: 4
|
40
|
+
:sql: SELECT * FROM south_mauricio
|
41
|
+
app/models/south_mauricio.rb:86:in `street_name':
|
42
|
+
:count: 1082
|
43
|
+
:sql: SELECT * FROM south_mauricio
|
44
|
+
app/models/south_mauricio.rb:63:in `state':
|
45
|
+
:count: 1006
|
46
|
+
:sql: SELECT * FROM south_mauricio
|
47
|
+
east_curtfort:
|
48
|
+
:count: 1086
|
49
|
+
:location:
|
50
|
+
app/models/east_curtfort.rb:62:in `street_name':
|
51
|
+
:count: 1
|
52
|
+
:sql: SELECT * FROM east_curtfort
|
53
|
+
app/models/east_curtfort.rb:87:in `city':
|
54
|
+
:count: 1082
|
55
|
+
:sql: SELECT * FROM east_curtfort
|
56
|
+
app/models/east_curtfort.rb:29:in `zip_code':
|
57
|
+
:count: 3
|
58
|
+
:sql: SELECT * FROM east_curtfort
|
59
|
+
new_damionview:
|
60
|
+
:count: 4
|
61
|
+
:location:
|
62
|
+
app/models/new_damionview.rb:59:in `longitude':
|
63
|
+
:count: 1
|
64
|
+
:sql: SELECT * FROM new_damionview
|
65
|
+
app/models/new_damionview.rb:22:in `city':
|
66
|
+
:count: 3
|
67
|
+
:sql: SELECT * FROM new_damionview
|
68
|
+
hudsonborough:
|
69
|
+
:count: 1424
|
70
|
+
:location:
|
71
|
+
app/models/hudsonborough.rb:67:in `country':
|
72
|
+
:count: 1084
|
73
|
+
:sql: SELECT * FROM hudsonborough
|
74
|
+
app/models/hudsonborough.rb:69:in `zip_code':
|
75
|
+
:count: 288
|
76
|
+
:sql: SELECT * FROM hudsonborough
|
77
|
+
app/models/hudsonborough.rb:53:in `zip_code':
|
78
|
+
:count: 26
|
79
|
+
:sql: SELECT * FROM hudsonborough
|
80
|
+
app/models/hudsonborough.rb:23:in `city':
|
81
|
+
:count: 26
|
82
|
+
:sql: SELECT * FROM hudsonborough
|
83
|
+
port_richmouth:
|
84
|
+
:count: 806
|
85
|
+
:location:
|
86
|
+
app/models/port_richmouth.rb:49:in `latitude':
|
87
|
+
:count: 806
|
88
|
+
:sql: SELECT * FROM port_richmouth
|
89
|
+
north_felica:
|
90
|
+
:count: 1084
|
91
|
+
:location:
|
92
|
+
app/models/north_felica.rb:46:in `zip_code':
|
93
|
+
:count: 1084
|
94
|
+
:sql: SELECT * FROM north_felica
|
95
|
+
east_arnoldfurt:
|
96
|
+
:count: 3173
|
97
|
+
:location:
|
98
|
+
app/models/east_arnoldfurt.rb:47:in `building_number':
|
99
|
+
:count: 4
|
100
|
+
:sql: SELECT * FROM east_arnoldfurt
|
101
|
+
app/models/east_arnoldfurt.rb:53:in `latitude':
|
102
|
+
:count: 3169
|
103
|
+
:sql: SELECT * FROM east_arnoldfurt
|
104
|
+
new_nga:
|
105
|
+
:count: 6204
|
106
|
+
:location:
|
107
|
+
app/models/new_nga.rb:20:in `zip_code':
|
108
|
+
:count: 4
|
109
|
+
:sql: SELECT * FROM new_nga
|
110
|
+
app/models/new_nga.rb:84:in `latitude':
|
111
|
+
:count: 3169
|
112
|
+
:sql: SELECT * FROM new_nga
|
113
|
+
app/models/new_nga.rb:81:in `country':
|
114
|
+
:count: 3018
|
115
|
+
:sql: SELECT * FROM new_nga
|
116
|
+
app/models/new_nga.rb:62:in `building_number':
|
117
|
+
:count: 13
|
118
|
+
:sql: SELECT * FROM new_nga
|
119
|
+
port_allenastad:
|
120
|
+
:count: 1082
|
121
|
+
:location:
|
122
|
+
app/models/port_allenastad.rb:57:in `street_name':
|
123
|
+
:count: 1082
|
124
|
+
:sql: SELECT * FROM port_allenastad
|
125
|
+
north_tad:
|
126
|
+
:count: 2278
|
127
|
+
:location:
|
128
|
+
app/models/north_tad.rb:48:in `state':
|
129
|
+
:count: 2278
|
130
|
+
:sql: SELECT * FROM north_tad
|
131
|
+
vanmouth:
|
132
|
+
:count: 1082
|
133
|
+
:location:
|
134
|
+
app/models/vanmouth.rb:34:in `country':
|
135
|
+
:count: 1082
|
136
|
+
:sql: SELECT * FROM vanmouth
|
137
|
+
windlerport:
|
138
|
+
:count: 4
|
139
|
+
:location:
|
140
|
+
app/models/windlerport.rb:98:in `city':
|
141
|
+
:count: 4
|
142
|
+
:sql: SELECT * FROM windlerport
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../lib/active_record_query_count'
|
2
|
+
require 'pry-byebug'
|
3
|
+
|
4
|
+
data_1 = File.read('scripts_for_testing/example_script_unoptimize.yaml')
|
5
|
+
data_2 = File.read('scripts_for_testing/example_script_optimize.yaml')
|
6
|
+
data_1 = YAML.safe_load(data_1, permitted_classes: [Proc, Symbol])
|
7
|
+
data_2 = YAML.safe_load(data_2, permitted_classes: [Proc, Symbol])
|
8
|
+
ActiveRecordQueryCount.compare do |comparing|
|
9
|
+
comparing.code('First code block') do
|
10
|
+
ActiveRecordQueryCount.tracker.instance_variable_set :@active_record_query_tracker, data_1
|
11
|
+
end
|
12
|
+
comparing.code('Second code block') do
|
13
|
+
ActiveRecordQueryCount.tracker.instance_variable_set :@active_record_query_tracker, data_2
|
14
|
+
end
|
15
|
+
comparing.compare!
|
16
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative '../lib/active_record_query_count'
|
2
|
+
require 'pry-byebug'
|
3
|
+
|
4
|
+
data = File.read('scripts_for_testing/example_script_unoptimize.yaml')
|
5
|
+
data = YAML.safe_load(data, permitted_classes: [Proc, Symbol])
|
6
|
+
ActiveRecordQueryCount.start_with_block(printer: :html) do
|
7
|
+
ActiveRecordQueryCount.tracker.instance_variable_set :@active_record_query_tracker, data
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative '../lib/active_record_query_count'
|
2
|
+
require 'pry-byebug'
|
3
|
+
|
4
|
+
data = File.read('scripts_for_testing/example_script_unoptimize.yaml')
|
5
|
+
data = YAML.safe_load(data, permitted_classes: [Proc, Symbol])
|
6
|
+
ActiveRecordQueryCount.start_with_block(printer: :console) do
|
7
|
+
ActiveRecordQueryCount.tracker.instance_variable_set :@active_record_query_tracker, data
|
8
|
+
end
|