query_diet 0.7.2 → 0.7.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: adc811cbb6edd8cca833ee1aa21c21bffd0462033efcc285ee823f60cc11fcb5
4
- data.tar.gz: faf9dc0518a10f0809c6412b724abc35739d9a42228667f4a9061a1e70279e14
3
+ metadata.gz: e0dcbe12b6aeaf62fea07ee16bf3856aa09d849dcee601bd9d66611939d11384
4
+ data.tar.gz: 00bd178162c5eb27e9928a72c9e242112e0a6db411cb79c8e38d5fd4861060ad
5
5
  SHA512:
6
- metadata.gz: c6dce92be326127f4bdff50baa94df1fb483be0819071a691cc76bc516aa46175c94b5394d5753a4018298b658c5d30a24003134dae0f609f5c6f77ff70be7bd
7
- data.tar.gz: 1e532fa2a7d53732881cfccdaed64e3d2bddfd0ba0f484cd0a02e598d0cebf4d1d2183eff0481034e7e710df629e2f8282cb3608d01db4d7b2f7e257186bf2fd
6
+ metadata.gz: 1fb3c23580b461f2e9f999bd1ae5bc8a68b0c2b0230136f93f01b2779d443664adb34e24fdcd56a4e01030154aa4d068ff8c0ce82fe61cb3bf2de83018762cf9
7
+ data.tar.gz: 7a4a4840f4798129c983e00729d68d000d050a787ea763a122269eb93f677cf905d45e3fbc521dae4e69aa4562f2fe8a8e04dabfe984d2e0e424a409d418f7df
data/README.md CHANGED
@@ -1,5 +1,21 @@
1
- Query Diet [![Tests](https://github.com/makandra/query_diet/workflows/Tests/badge.svg)](https://github.com/makandra/query_diet/actions)
2
- ==========
1
+ <p>
2
+ <a href="https://makandra.de/">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: light)" srcset="media/makandra-with-bottom-margin.light.svg">
5
+ <source media="(prefers-color-scheme: dark)" srcset="media/makandra-with-bottom-margin.dark.svg">
6
+ <img align="right" width="25%" alt="makandra" src="media/makandra-with-bottom-margin.light.svg">
7
+ </picture>
8
+ </a>
9
+
10
+ <picture>
11
+ <source media="(prefers-color-scheme: light)" srcset="media/logo.light.shapes.svg">
12
+ <source media="(prefers-color-scheme: dark)" srcset="media/logo.dark.shapes.svg">
13
+ <img width="215" alt="Query Diet" role="heading" aria-level="1" src="media/logo.light.shapes.svg">
14
+ </picture>
15
+ </p>
16
+
17
+ [![Tests](https://github.com/makandra/query_diet/workflows/Tests/badge.svg)](https://github.com/makandra/query_diet/actions)
18
+
3
19
 
4
20
  Query Diet counts the number of database queries for the last request and *subtly* displays it in the upper right corner of your screen.
5
21
  The display turns red if too many queries are run, or if they take too long.
@@ -7,11 +23,11 @@ This is useful to prevent [N + 1 queries](http://guides.rubyonrails.org/active_r
7
23
 
8
24
  This is Query Diet being happy about 3 requests taking 66ms:
9
25
 
10
- ![](http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_happy.png)
26
+ ![Query Diet is happy](media/query_diet_happy.png)
11
27
 
12
28
  This is Query Diet being angry about 103 requests taking 164ms:
13
29
 
14
- ![](http://blog.makandra.com/images/articles/2010-06-25-solving-the-n-1-query-problem-with-query-diet/query_diet_angry.png)
30
+ ![Query Diet is angry](media/query_diet_angry.png)
15
31
 
16
32
 
17
33
  Installation
@@ -67,7 +83,19 @@ Rails.application.config.content_security_policy do |policy|
67
83
 
68
84
  ### Rails compatibility
69
85
 
70
- The gem is tested to work with Rails 3.2+ and Ruby 2.5.8+.
86
+ The gem is tested against
87
+
88
+ | Versions | Ruby 2.7.8 | Ruby 3.0.0 | Ruby 3.1.6 | Ruby 3.3.4 | Ruby 3.4.4 |
89
+ |-----------|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|
90
+ | Rails 6.1 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
91
+ | Rails 7.0 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
92
+ | Rails 7.1 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
93
+ | Rails 7.2 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
94
+ | Rails 8.0 | :x: | :x: | :x: | :heavy_check_mark: | :x: |
95
+ | Rails 8.1 | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
96
+
97
+
98
+ Later versions might work, earlier will not.
71
99
 
72
100
  For Rails 2.3 and Ruby 1.8.7 support, use a version < 0.6.
73
101
 
@@ -1,6 +1,6 @@
1
1
  module QueryDiet
2
2
  module ActiveRecordExt
3
- if RUBY_VERSION >= '3'
3
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3')
4
4
  def log(query, *, **)
5
5
  QueryDiet::Logger.log(query) { super }
6
6
  end
@@ -0,0 +1,11 @@
1
+ module QueryDiet
2
+ module Benchmark
3
+ class << self
4
+ def realtime
5
+ r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
6
+ yield
7
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0
8
+ end
9
+ end
10
+ end
11
+ end
@@ -14,7 +14,7 @@ module QueryDiet
14
14
  yield
15
15
  else
16
16
  result = nil
17
- time = Benchmark.realtime do
17
+ time = QueryDiet::Benchmark.realtime do
18
18
  result = yield
19
19
  end
20
20
  queries << [query, time] if log_query?(query)
@@ -1,3 +1,3 @@
1
1
  module QueryDiet
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
@@ -0,0 +1,19 @@
1
+ module QueryDiet
2
+ module Widget
3
+ module Helper
4
+
5
+ def query_diet_widget(options = {})
6
+ default_html_options = {:nonce => false}
7
+ options = options.reverse_merge(default_html_options)
8
+
9
+ nonce_attribute = options.fetch(:nonce) ? " nonce=\"#{content_security_policy_nonce}\"" : ''
10
+
11
+ html = Widget.css(nonce_attribute) + Widget.html(options) + Widget.js(nonce_attribute)
12
+ html.respond_to?(:html_safe) ? html.html_safe : html
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+
19
+ ActionView::Base.send :include, QueryDiet::Widget::Helper
@@ -50,21 +50,7 @@ module QueryDiet
50
50
  end
51
51
 
52
52
  end
53
-
54
- module Helper
55
- def query_diet_widget(options = {})
56
- default_html_options = {:nonce => false}
57
- options = options.reverse_merge(default_html_options)
58
-
59
- nonce_attribute = options.fetch(:nonce) ? " nonce=\"#{content_security_policy_nonce}\"" : ''
60
-
61
- html = Widget.css(nonce_attribute) + Widget.html(options) + Widget.js(nonce_attribute)
62
- html.respond_to?(:html_safe) ? html.html_safe : html
63
- end
64
- end
65
-
66
53
  end
67
-
68
54
  end
69
55
 
70
- ActionView::Base.send :include, QueryDiet::Widget::Helper
56
+ require 'query_diet/widget/helper'
data/lib/query_diet.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'query_diet/benchmark'
1
2
  require 'query_diet/logger'
2
3
  require 'query_diet/widget'
3
4
  require 'query_diet/active_record_ext'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: query_diet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  - Tobias Kraze
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-21 00:00:00.000000000 Z
12
+ date: 2025-10-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rails database query counter that stays out of your way
15
15
  email: github@makandra.de
@@ -17,20 +17,24 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - MIT-LICENSE
21
20
  - README.md
22
21
  - lib/query_diet.rb
23
22
  - lib/query_diet/active_record_ext.rb
23
+ - lib/query_diet/benchmark.rb
24
24
  - lib/query_diet/logger.rb
25
25
  - lib/query_diet/rack/reset_logger.rb
26
26
  - lib/query_diet/version.rb
27
27
  - lib/query_diet/widget.rb
28
+ - lib/query_diet/widget/helper.rb
28
29
  homepage: https://github.com/makandra/query_diet
29
30
  licenses:
30
31
  - MIT
31
32
  metadata:
33
+ source_code_uri: https://github.com/makandra/query_diet
34
+ bug_tracker_uri: https://github.com/makandra/query_diet/issues
35
+ changelog_uri: https://github.com/makandra/query_diet/blob/master/CHANGELOG.md
32
36
  rubygems_mfa_required: 'true'
33
- post_install_message:
37
+ post_install_message:
34
38
  rdoc_options: []
35
39
  require_paths:
36
40
  - lib
@@ -45,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
49
  - !ruby/object:Gem::Version
46
50
  version: '0'
47
51
  requirements: []
48
- rubygems_version: 3.5.11
49
- signing_key:
52
+ rubygems_version: 3.5.22
53
+ signing_key:
50
54
  specification_version: 4
51
55
  summary: Rails database query counter that stays out of your way
52
56
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Henning Koch
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.