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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2665c7f88ca9768ac7752bef6b0bc52832dc6ac18a927d9ddf70a57aed37484e
4
- data.tar.gz: f4db4b39542134ea3ef509269c32885c59875e0b347b45731b94a7a4656459a4
3
+ metadata.gz: 8e5b613fb399fad52dcc34c659d6c62606015ccadc1f838281e80762099060e1
4
+ data.tar.gz: 1205634307360f5da76fec91adf9db65f254060cfcebea1bfc3fa2260f6ad2e1
5
5
  SHA512:
6
- metadata.gz: d791a56860bc7c0aec9994f23c0a3e588c0735cd1feb139e496473f804fa7482a845fefec62efff1efb8c324a93165cbf759b75c1b1b5b37fa9ca24ae1ee8cf5
7
- data.tar.gz: d2d1eeef0f9894616617f8b39c498678ea43bc67823a777c34966ce7ad03538d6a5c641b745bd6ba37f52a64a5c8821fbe3957c73266f85b3c44b456aa897793
6
+ metadata.gz: 13a3e0d6c85ca4093e0b5ebe6c4c1a8b5937e3f24b183f57df7d0a1cf316b641844335254891c4687b5576eb98f85e725bc90b06f4a1d5e3da1e1b055f1c82ca
7
+ data.tar.gz: 86da8fdcc6868e821c6cbaa3fb53d7ec55c0d62e2d98534fd953ae96cac8a00bc06e1897145cb603e4c774158a35951b4ab9d2607ccc3e8f554f98b541929367
data/.gitignore CHANGED
@@ -11,3 +11,5 @@
11
11
  .rspec_status
12
12
 
13
13
  .DS_Store
14
+
15
+ sql_monitor-*.gem
@@ -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
- source: row[:source].uniq.join("<br/>")
68
+ sources: sources
61
69
  })
62
70
  end
63
71
  formatedData
@@ -53,6 +53,14 @@
53
53
  background-color: navajowhite;
54
54
  }
55
55
 
56
+ table {
57
+ table-layout: fixed;
58
+ width: 100%;
59
+ }
60
+
61
+ table td {
62
+ word-wrap: break-word;
63
+ }
56
64
  </style>
57
65
  </head>
58
66
  <body>
@@ -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><%=raw d[:source] %></td>
60
+ <td>
61
+ <% d[:sources].each_with_index do |s, idx| %>
62
+ <%= idx + 1 %>.&nbsp;<a href="<%= s[0] %>" target="_blank"><%= s[1] %></a>
63
+ <% end %>
64
+ </td>
61
65
  </tr>
62
66
  <% end %>
63
67
  </table>
@@ -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)
@@ -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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sql_monitor".freeze
6
- s.version = "0.1.0"
6
+ s.version = "0.1.3"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tade