dial 0.1.4 → 0.1.6

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: 61252b82f8769e8c0724a9cb40a8771afc59df61de01847add599037939b1e7d
4
- data.tar.gz: 3944fe8e444853a4dfe4f2fb474bf6ed6a4b30814d55dc127df986e99c08bcf6
3
+ metadata.gz: 4267ea5bc603e20d21e2cc7956154d210a7aad2441a4088c517adee6f9e630a5
4
+ data.tar.gz: 57de7d2c3bf2cd8055c3e180ff745b95b8541176f0e8aea6ec05a69f5d1175c5
5
5
  SHA512:
6
- metadata.gz: cdbc7c51f7392b280a56f56d232204c93ee77e436ee6891f7f88e9d9c39570b77b85af3ff07dc15a54c854757053be0ab8c85d7adb6c21ed23f438c43c0d4da7
7
- data.tar.gz: 8b8b5400414355f6012d87b490b719ab3b79cfacc229705e752e8822162cc383979e8898711f76b0b1393c497ec0c5a0cd4a344f9050ab1832e1317b314c30bd
6
+ metadata.gz: 82995a0e0d7898af69ea939db4081214844e5b5de7f911be3c6e61ce51d9446d4abeda7dccd0be882c5efabd49267cdcfd2a042ae9c066b1c163f3e68ec1a0ee
7
+ data.tar.gz: f5b75425302efda23211c8a87ef94f543d9b253ccb5965d04067db2f81c05c9ad1d2432d222419ccd6ed08dfa90d7243f42452a695c3faaa79f7c5aa5d8bdab3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.6] - 2025-01-25
4
+
5
+ - Fix redeclaration of JS constants
6
+
7
+ ## [0.1.5] - 2025-01-24
8
+
9
+ - UI: Fix overflow and add vertical scroll
10
+
3
11
  ## [0.1.4] - 2024-12-27
4
12
 
5
13
  - Use vernier memory usage and rails hooks by default
data/README.md CHANGED
@@ -12,18 +12,24 @@ Check out the demo:
12
12
 
13
13
  ## Installation
14
14
 
15
- 1. Install the gem and add it to your Rails application's Gemfile by executing:
15
+ 1. Add the gem to your Rails application's Gemfile (adjust the `require` option to match your server of choice):
16
16
 
17
- ```bash
18
- bundle add dial
17
+ ```ruby
18
+ # require in just the server process
19
+ gem "dial", require: !!($PROGRAM_NAME =~ /puma/)
19
20
  ```
20
21
 
21
- 2. Mount the engine in your `config/routes.rb` file:
22
+ 2. Install the gem:
23
+
24
+ ```bash
25
+ bundle install
26
+ ```
22
27
 
28
+ 3. Mount the engine in your `config/routes.rb` file:
23
29
 
24
30
  ```ruby
25
31
  # this will mount the engine at /dial
26
- mount Dial::Engine, at: "/"
32
+ mount Dial::Engine, at: "/" if Object.const_defined? "Dial::Engine"
27
33
  ```
28
34
 
29
35
  ## Development
data/dial.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency "railties", ">= 7", "< 8.2"
23
23
  spec.add_dependency "activerecord", ">= 7", "< 8.2"
24
24
  spec.add_dependency "actionpack", ">= 7", "< 8.2"
25
- spec.add_dependency "vernier", "~> 1.5"
26
- spec.add_dependency "prosopite", "~> 1.4"
27
- spec.add_dependency "pg_query", "~> 5.1"
25
+ spec.add_dependency "vernier"
26
+ spec.add_dependency "prosopite"
27
+ spec.add_dependency "pg_query"
28
28
  end
@@ -6,7 +6,7 @@ module Dial
6
6
  REQUEST_TIMING_HEADER = "dial_request_timing"
7
7
 
8
8
  PROFILE_OUT_STALE_SECONDS = 60 * 60
9
- PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/profile/"
9
+ PROFILE_OUT_RELATIVE_DIRNAME = "tmp/dial/profiles/"
10
10
 
11
11
  PROSOPITE_IGNORE_QUERIES = [/schema_migrations/]
12
12
  PROSOPITE_LOG_RELATIVE_PATHNAME = "log/dial/prosopite.log"
@@ -21,7 +21,16 @@ module Dial
21
21
  <span>#{formatted_ruby_version}</span>
22
22
  </div>
23
23
 
24
+ <hr>
25
+
24
26
  <div id="dial-details">
27
+ <details>
28
+ <summary>N+1s</summary>
29
+ <div class="section query-logs">
30
+ #{formatted_query_logs query_logs}
31
+ </div>
32
+ </details>
33
+
25
34
  <hr>
26
35
 
27
36
  <details>
@@ -31,12 +40,7 @@ module Dial
31
40
  </div>
32
41
  </details>
33
42
 
34
- <details>
35
- <summary>N+1s</summary>
36
- <div class="section query-logs">
37
- #{formatted_query_logs query_logs}
38
- </div>
39
- </details>
43
+ <hr>
40
44
 
41
45
  <details>
42
46
  <summary>RubyVM stat</summary>
@@ -45,6 +49,8 @@ module Dial
45
49
  </div>
46
50
  </details>
47
51
 
52
+ <hr>
53
+
48
54
  <details>
49
55
  <summary>GC stat</summary>
50
56
  <div class="section">
@@ -52,6 +58,8 @@ module Dial
52
58
  </div>
53
59
  </details>
54
60
 
61
+ <hr>
62
+
55
63
  <details>
56
64
  <summary>GC stat heap</summary>
57
65
  <div class="section">
@@ -70,6 +78,8 @@ module Dial
70
78
  def style
71
79
  <<~CSS
72
80
  #dial {
81
+ max-height: 50%;
82
+ max-width: 50%;
73
83
  z-index: 9999;
74
84
  position: fixed;
75
85
  bottom: 0;
@@ -91,6 +101,7 @@ module Dial
91
101
 
92
102
  #dial-details {
93
103
  display: none;
104
+ overflow-y: auto;
94
105
  }
95
106
 
96
107
  .section {
@@ -104,6 +115,7 @@ module Dial
104
115
 
105
116
  details {
106
117
  margin-top: 0;
118
+ margin-bottom: 0.25rem;
107
119
  }
108
120
  }
109
121
 
@@ -114,6 +126,7 @@ module Dial
114
126
  hr {
115
127
  width: -moz-available;
116
128
  margin: 0.65rem 0 0 0;
129
+ background-color: black;
117
130
  }
118
131
 
119
132
  details {
@@ -131,12 +144,24 @@ module Dial
131
144
 
132
145
  def script
133
146
  <<~JS
134
- const dialPreview = document.getElementById("dial-preview");
135
- const dialDetails = document.getElementById("dial-details");
147
+ var dialPreview = document.getElementById("dial-preview");
148
+ var dialDetails = document.getElementById("dial-details");
149
+
136
150
  dialPreview.addEventListener("click", () => {
137
- const collapsed = ["", "none"].includes(dialDetails.style.display);
151
+ var collapsed = ["", "none"].includes(dialDetails.style.display);
138
152
  dialDetails.style.display = collapsed ? "block" : "none";
139
153
  });
154
+
155
+ document.addEventListener("click", (event) => {
156
+ if (!dialPreview.contains(event.target) && !dialDetails.contains(event.target)) {
157
+ dialDetails.style.display = "none";
158
+
159
+ var detailsElements = dialDetails.querySelectorAll("details");
160
+ detailsElements.forEach(detail => {
161
+ detail.removeAttribute("open");
162
+ });
163
+ }
164
+ });
140
165
  JS
141
166
  end
142
167
 
@@ -178,7 +203,6 @@ module Dial
178
203
  def formatted_server_timing server_timing
179
204
  if server_timing.any?
180
205
  server_timing
181
- # TODO: Nested sorting
182
206
  .sort_by { |_, timing| -timing }
183
207
  .map { |event, timing| "<span><b>#{event}:</b> #{timing}</span>" }.join
184
208
  else
@@ -187,17 +211,21 @@ module Dial
187
211
  end
188
212
 
189
213
  def formatted_query_logs query_logs
190
- query_logs.map do |(queries, stack_lines)|
191
- <<~HTML
192
- <details>
193
- <summary>#{queries.shift}</summary>
194
- <div class="section query-logs">
195
- #{queries.map { |query| "<span>#{query}</span>" }.join}
196
- #{stack_lines.map { |stack_line| "<span>#{stack_line}</span>" }.join}
197
- </div>
198
- </details>
199
- HTML
200
- end.join
214
+ if query_logs.any?
215
+ query_logs.map do |(queries, stack_lines)|
216
+ <<~HTML
217
+ <details>
218
+ <summary>#{queries.shift}</summary>
219
+ <div class="section query-logs">
220
+ #{queries.map { |query| "<span>#{query}</span>" }.join}
221
+ #{stack_lines.map { |stack_line| "<span>#{stack_line}</span>" }.join}
222
+ </div>
223
+ </details>
224
+ HTML
225
+ end.join
226
+ else
227
+ "NA"
228
+ end
201
229
  end
202
230
 
203
231
  def formatted_ruby_vm_stat ruby_vm_stat
@@ -93,32 +93,10 @@ module Dial
93
93
  def clear_query_logs!
94
94
  [].tap do |query_logs|
95
95
  File.open(query_log_pathname, "r+") do |file|
96
- entry = reading_section = query_count = nil
96
+ entry = section = count = nil
97
97
  file.each_line do |line|
98
- case line
99
- when /N\+1 queries detected/
100
- entry = [[], []]
101
- reading_section = :queries
102
- query_count = 0
103
- when /Call stack/
104
- reading_section = :call_stack
105
- if query_count > 5
106
- entry.first << "+ #{query_count - 5} more queries"
107
- end
108
- else
109
- case reading_section
110
- when :queries
111
- query_count += 1
112
- entry.first << line.strip if query_count <= 5
113
- when :call_stack
114
- if line.strip.empty?
115
- query_logs << entry
116
- reading_section = nil
117
- else
118
- entry.last << line.strip
119
- end
120
- end
121
- end
98
+ entry, section, count = process_query_log_line line, entry, section, count
99
+ query_logs << entry if entry && section.nil?
122
100
  end
123
101
 
124
102
  file.truncate 0
@@ -127,6 +105,30 @@ module Dial
127
105
  end
128
106
  end
129
107
 
108
+ def process_query_log_line line, entry, section, count
109
+ case line
110
+ when /N\+1 queries detected/
111
+ [[[],[]], :queries, 0]
112
+ when /Call stack/
113
+ entry.first << "+ #{count - 5} more queries" if count > 5
114
+ [entry, :call_stack, count]
115
+ else
116
+ case section
117
+ when :queries
118
+ count += 1
119
+ entry.first << line.strip if count <= 5
120
+ [entry, :queries, count]
121
+ when :call_stack
122
+ if line.strip.empty?
123
+ [entry, nil, count]
124
+ else
125
+ entry.last << line.strip
126
+ [entry, section, count]
127
+ end
128
+ end
129
+ end
130
+ end
131
+
130
132
  def query_log_pathname
131
133
  @_query_log_dir_pathname ||= ::Rails.root.join PROSOPITE_LOG_RELATIVE_PATHNAME
132
134
  end
data/lib/dial/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dial
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2024-12-27 00:00:00.000000000 Z
10
+ date: 2025-01-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: railties
@@ -73,44 +73,44 @@ dependencies:
73
73
  name: vernier
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - "~>"
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
- version: '1.5'
78
+ version: '0'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - "~>"
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: '1.5'
85
+ version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: prosopite
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - "~>"
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '1.4'
92
+ version: '0'
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: '1.4'
99
+ version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: pg_query
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - "~>"
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '5.1'
106
+ version: '0'
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - "~>"
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
- version: '5.1'
113
+ version: '0'
114
114
  email:
115
115
  - djry1999@gmail.com
116
116
  executables: []