sql_monitor 0.1.2 → 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
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
|
@@ -45,15 +45,27 @@ module SqlMonitor
|
|
45
45
|
end
|
46
46
|
end
|
47
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
|
+
|
48
55
|
def format_data(sorted_data)
|
49
56
|
formatedData = [];
|
50
57
|
sorted_data.each do |row|
|
58
|
+
sources = []
|
59
|
+
row[:source].uniq.each do |s|
|
60
|
+
sources << format_source(s)
|
61
|
+
end
|
62
|
+
|
51
63
|
formatedData.push({
|
52
64
|
sql_key: row[:sql_key],
|
53
65
|
count: row[:count].to_s,
|
54
66
|
duration: row[:duration].to_f / row[:count],
|
55
67
|
sql: row[:sql],
|
56
|
-
|
68
|
+
sources: sources
|
57
69
|
})
|
58
70
|
end
|
59
71
|
formatedData
|
@@ -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
data/sql_monitor.gemspec
CHANGED