Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ jobs:
gemfile: Gemfile.7.2.sqlite
- ruby: 3.3.4
gemfile: Gemfile.8.0.sqlite
- ruby: 3.4.4
gemfile: Gemfile.8.0.sqlite
- ruby: 3.4.4
gemfile: Gemfile.8.1.sqlite
env:
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.4.4
4 changes: 3 additions & 1 deletion Gemfile.7.0.sqlite.lock
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.2)
mini_portile2 (2.8.9)
minitest (5.25.1)
net-imap (0.2.3)
digest
Expand All @@ -127,7 +128,8 @@ GEM
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.18.10)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
public_suffix (4.0.6)
racc (1.8.1)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.8.0.sqlite.lock
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.4)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.18.10-x86_64-linux-gnu)
racc (~> 1.4)
psych (5.1.2)
stringio
Expand Down Expand Up @@ -209,7 +209,7 @@ GEM
rspec-support (~> 3.13)
rspec-support (3.13.1)
securerandom (0.3.1)
sqlite3 (2.4.1-x86_64-linux-gnu)
sqlite3 (2.7.4-x86_64-linux-gnu)
stringio (3.1.1)
thor (1.3.2)
timeout (0.4.1)
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.8.1.sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source 'https://rubygems.org'

# Runtime dependencies
gem 'rails', '=8.1.0'

# Development dependencies
gem 'rspec'
gem 'rspec-rails'
gem 'sqlite3', '~> 2.4'
gem 'database_cleaner'
gem 'capybara'
gem 'byebug'
gem 'gemika'

# Gem under test
gem 'query_diet', :path => '.'
257 changes: 257 additions & 0 deletions Gemfile.8.1.sqlite.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
PATH
remote: .
specs:
query_diet (0.7.2)

GEM
remote: https://rubygems.org/
specs:
action_text-trix (2.1.15)
railties
actioncable (8.1.0)
actionpack (= 8.1.0)
activesupport (= 8.1.0)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
zeitwerk (~> 2.6)
actionmailbox (8.1.0)
actionpack (= 8.1.0)
activejob (= 8.1.0)
activerecord (= 8.1.0)
activestorage (= 8.1.0)
activesupport (= 8.1.0)
mail (>= 2.8.0)
actionmailer (8.1.0)
actionpack (= 8.1.0)
actionview (= 8.1.0)
activejob (= 8.1.0)
activesupport (= 8.1.0)
mail (>= 2.8.0)
rails-dom-testing (~> 2.2)
actionpack (8.1.0)
actionview (= 8.1.0)
activesupport (= 8.1.0)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actiontext (8.1.0)
action_text-trix (~> 2.1.15)
actionpack (= 8.1.0)
activerecord (= 8.1.0)
activestorage (= 8.1.0)
activesupport (= 8.1.0)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (8.1.0)
activesupport (= 8.1.0)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activejob (8.1.0)
activesupport (= 8.1.0)
globalid (>= 0.3.6)
activemodel (8.1.0)
activesupport (= 8.1.0)
activerecord (8.1.0)
activemodel (= 8.1.0)
activesupport (= 8.1.0)
timeout (>= 0.4.0)
activestorage (8.1.0)
actionpack (= 8.1.0)
activejob (= 8.1.0)
activerecord (= 8.1.0)
activesupport (= 8.1.0)
marcel (~> 1.0)
activesupport (8.1.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
json
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.3.0)
bigdecimal (3.3.1)
builder (3.3.0)
byebug (12.0.0)
capybara (3.40.0)
addressable
matrix
mini_mime (>= 0.1.3)
nokogiri (~> 1.11)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
concurrent-ruby (1.3.5)
connection_pool (2.5.4)
crass (1.0.6)
database_cleaner (2.1.0)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.2.2)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0)
database_cleaner-core (2.0.1)
date (3.4.1)
diff-lcs (1.6.2)
drb (2.2.3)
erb (5.1.1)
erubi (1.13.1)
gemika (1.0.0)
globalid (1.3.0)
activesupport (>= 6.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
io-console (0.8.1)
irb (1.15.2)
pp (>= 0.6.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.15.2)
logger (1.7.0)
loofah (2.24.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.9.0)
logger
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.1.0)
matrix (0.4.3)
mini_mime (1.1.5)
minitest (5.26.0)
net-imap (0.5.12)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.10-x86_64-linux-gnu)
racc (~> 1.4)
pp (0.6.3)
prettyprint
prettyprint (0.2.0)
psych (5.2.6)
date
stringio
public_suffix (6.0.2)
racc (1.8.1)
rack (3.2.3)
rack-session (2.1.1)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.2.0)
rack (>= 1.3)
rackup (2.2.1)
rack (>= 3)
rails (8.1.0)
actioncable (= 8.1.0)
actionmailbox (= 8.1.0)
actionmailer (= 8.1.0)
actionpack (= 8.1.0)
actiontext (= 8.1.0)
actionview (= 8.1.0)
activejob (= 8.1.0)
activemodel (= 8.1.0)
activerecord (= 8.1.0)
activestorage (= 8.1.0)
activesupport (= 8.1.0)
bundler (>= 1.15.0)
railties (= 8.1.0)
rails-dom-testing (2.3.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.0)
actionpack (= 8.1.0)
activesupport (= 8.1.0)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rake (13.3.0)
rdoc (6.15.0)
erb
psych (>= 4.0.0)
tsort
regexp_parser (2.11.3)
reline (0.6.2)
io-console (~> 0.5)
rspec (3.13.2)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.6)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (8.0.2)
actionpack (>= 7.2)
activesupport (>= 7.2)
railties (>= 7.2)
rspec-core (~> 3.13)
rspec-expectations (~> 3.13)
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.6)
securerandom (0.4.1)
sqlite3 (2.7.4-x86_64-linux-gnu)
stringio (3.1.7)
thor (1.4.0)
timeout (0.4.3)
tsort (0.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.0.4)
useragent (0.16.11)
websocket-driver (0.8.0)
base64
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.7.3)

PLATFORMS
x86_64-linux

DEPENDENCIES
byebug
capybara
database_cleaner
gemika
query_diet!
rails (= 8.1.0)
rspec
rspec-rails
sqlite3 (~> 2.4)

BUNDLED WITH
2.6.9
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ Rails.application.config.content_security_policy do |policy|

The gem is tested against

| Versions | Ruby 2.7.8 | Ruby 3.0.0 | Ruby 3.1.6 | Ruby 3.3.4 |
|-----------|:------------------:|:------------------:|:------------------:|:------------------:|
| Rails 6.1 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Rails 7.0 | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Rails 7.1 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Rails 7.2 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Rails 8.0 | :x: | :x: | :x: | :heavy_check_mark: |
| Versions | Ruby 2.7.8 | Ruby 3.0.0 | Ruby 3.1.6 | Ruby 3.3.4 | Ruby 3.4.4 |
|-----------|:------------------:|:------------------:|:------------------:|:------------------:|:------------------:|
| Rails 6.1 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: |
| Rails 7.0 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Rails 7.1 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Rails 7.2 | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Rails 8.0 | :x: | :x: | :x: | :heavy_check_mark: | :x: |
| Rails 8.1 | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: |


Later versions might work, earlier will not.
Expand Down
1 change: 1 addition & 0 deletions lib/query_diet.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'query_diet/benchmark'
require 'query_diet/logger'
require 'query_diet/widget'
require 'query_diet/active_record_ext'
Expand Down
11 changes: 11 additions & 0 deletions lib/query_diet/benchmark.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module QueryDiet
module Benchmark
class << self
def realtime
r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield
Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0
end
end
end
end
4 changes: 1 addition & 3 deletions lib/query_diet/logger.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'benchmark'

module QueryDiet
class Logger
DEFAULT_OPTIONS = { :bad_count => 8, :bad_time => 5000 }
Expand All @@ -16,7 +14,7 @@ def log(query)
yield
else
result = nil
time = Benchmark.realtime do
time = QueryDiet::Benchmark.realtime do
result = yield
end
queries << [query, time] if log_query?(query)
Expand Down
2 changes: 1 addition & 1 deletion spec/query_diet/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
end

def mock_realtime(seconds)
Benchmark.should_receive(:realtime).at_least(:once).and_wrap_original do |original_method, *args, &block|
expect(QueryDiet::Benchmark).to receive(:realtime).at_least(:once).and_wrap_original do |original_method, *args, &block|
original_method.call(*args, &block)
seconds
end
Expand Down