sql_monitor 0.1.0 → 0.1.3
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 +4 -4
- data/.gitignore +2 -0
- data/app/controllers/sql_monitor/tracking_sqls_controller.rb +13 -5
- data/app/views/layouts/base.html.erb +8 -0
- data/app/views/sql_monitor/tracking_sqls/index.html.erb +8 -4
- data/lib/sql_monitor/config.rb +2 -1
- data/lib/sql_monitor/handler.rb +1 -3
- data/sql_monitor.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5b613fb399fad52dcc34c659d6c62606015ccadc1f838281e80762099060e1
|
4
|
+
data.tar.gz: 1205634307360f5da76fec91adf9db65f254060cfcebea1bfc3fa2260f6ad2e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a3e0d6c85ca4093e0b5ebe6c4c1a8b5937e3f24b183f57df7d0a1cf316b641844335254891c4687b5576eb98f85e725bc90b06f4a1d5e3da1e1b055f1c82ca
|
7
|
+
data.tar.gz: 86da8fdcc6868e821c6cbaa3fb53d7ec55c0d62e2d98534fd953ae96cac8a00bc06e1897145cb603e4c774158a35951b4ab9d2607ccc3e8f554f98b541929367
|
data/.gitignore
CHANGED
@@ -22,10 +22,6 @@ module SqlMonitor
|
|
22
22
|
@versions = JSON.parse(SqlMonitor.handler.redis.get('all_versions'), {:symbolize_names => true})
|
23
23
|
end
|
24
24
|
|
25
|
-
@versions.each do |v|
|
26
|
-
v[:total] = SqlMonitor.handler.redis.get(v[:version] + "_total")
|
27
|
-
end
|
28
|
-
|
29
25
|
@data = []
|
30
26
|
@selectedVersion = ''
|
31
27
|
if params[:version]
|
@@ -49,15 +45,27 @@ module SqlMonitor
|
|
49
45
|
end
|
50
46
|
end
|
51
47
|
|
48
|
+
def format_source(s)
|
49
|
+
values = s.split(':')
|
50
|
+
return [values[0] + ":" + values[1], s] if SqlMonitor.handler.config.repo_url.nil?
|
51
|
+
|
52
|
+
[SqlMonitor.handler.config.repo_url % {file: values[0], line: values[1]}, s]
|
53
|
+
end
|
54
|
+
|
52
55
|
def format_data(sorted_data)
|
53
56
|
formatedData = [];
|
54
57
|
sorted_data.each do |row|
|
58
|
+
sources = []
|
59
|
+
row[:source].uniq.each do |s|
|
60
|
+
sources << format_source(s)
|
61
|
+
end
|
62
|
+
|
55
63
|
formatedData.push({
|
56
64
|
sql_key: row[:sql_key],
|
57
65
|
count: row[:count].to_s,
|
58
66
|
duration: row[:duration].to_f / row[:count],
|
59
67
|
sql: row[:sql],
|
60
|
-
|
68
|
+
sources: sources
|
61
69
|
})
|
62
70
|
end
|
63
71
|
formatedData
|
@@ -41,10 +41,10 @@
|
|
41
41
|
|
42
42
|
<table class="table table-bordered">
|
43
43
|
<tr>
|
44
|
-
<th>Count</th>
|
45
|
-
<th>Avg Time (ms)</th>
|
44
|
+
<th style="width: 5%">Count</th>
|
45
|
+
<th style="width: 10%">Avg Time (ms)</th>
|
46
46
|
<th>SQL Query</th>
|
47
|
-
<th></th>
|
47
|
+
<th style="width: 7%"></th>
|
48
48
|
<th style="width: 30%">Source</th>
|
49
49
|
</tr>
|
50
50
|
<% @data.each do |d| %>
|
@@ -57,7 +57,11 @@
|
|
57
57
|
</div>
|
58
58
|
</td>
|
59
59
|
<td><input type="button" class="btn btn-info btn-sm" data-sql-key="<%= d[:sql_key] %>" value="Explain"></td>
|
60
|
-
<td
|
60
|
+
<td>
|
61
|
+
<% d[:sources].each_with_index do |s, idx| %>
|
62
|
+
<%= idx + 1 %>. <a href="<%= s[0] %>" target="_blank"><%= s[1] %></a>
|
63
|
+
<% end %>
|
64
|
+
</td>
|
61
65
|
</tr>
|
62
66
|
<% end %>
|
63
67
|
</table>
|
data/lib/sql_monitor/config.rb
CHANGED
@@ -4,7 +4,7 @@ require 'uri'
|
|
4
4
|
module SqlMonitor
|
5
5
|
class Config
|
6
6
|
include ActiveSupport::Configurable
|
7
|
-
config_accessor :redis_host, :tracked_paths, :tracked_sql_command, :output_path, :enabled, :redis_db, :release_version, :save_at_exit
|
7
|
+
config_accessor :redis_host, :tracked_paths, :tracked_sql_command, :output_path, :enabled, :redis_db, :release_version, :save_at_exit, :repo_url, :branch
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def apply_defaults
|
@@ -13,6 +13,7 @@ module SqlMonitor
|
|
13
13
|
self.redis_db = redis_db.nil? ? 11 : redis_db
|
14
14
|
self.release_version = release_version.nil? ? (0...50).map { ('a'..'z').to_a[rand(26)] }.join : release_version
|
15
15
|
self.save_at_exit = save_at_exit.nil? ? false : save_at_exit
|
16
|
+
self.repo_url = repo_url.nil? ? nil : repo_url.gsub('git@github.com:', 'https://github.com/').gsub('.git', "/blob/#{branch}/%{file}#L%{line}")
|
16
17
|
|
17
18
|
self.enabled = enabled.nil? ? false : enabled
|
18
19
|
self.tracked_paths ||= %w(app lib)
|
data/lib/sql_monitor/handler.rb
CHANGED
@@ -7,7 +7,7 @@ require "pry"
|
|
7
7
|
#
|
8
8
|
module SqlMonitor
|
9
9
|
class Handler
|
10
|
-
attr_reader :data, :cachedVerKey, :redis
|
10
|
+
attr_reader :data, :cachedVerKey, :redis, :config
|
11
11
|
|
12
12
|
def initialize(config)
|
13
13
|
@config = config
|
@@ -121,8 +121,6 @@ module SqlMonitor
|
|
121
121
|
|
122
122
|
# store new data
|
123
123
|
@redis.set(@cachedVerKey + ':' + key, JSON.dump(@data[key]))
|
124
|
-
# total sql keys
|
125
|
-
@redis.set(@cachedVerKey + '_total', @data.keys.count)
|
126
124
|
|
127
125
|
@data
|
128
126
|
end
|
data/sql_monitor.gemspec
CHANGED