rails-pg-extras 5.1.0 → 5.2.0

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: 1f7109cdaf06d94ed2a1707fffcd477a471c84ece3e648e4279f602f27e89b67
4
- data.tar.gz: 583b204cfad10e9c3602946d5e00d0c10eaf1a7407e7234fc1f22db154e22bab
3
+ metadata.gz: f2e57fcbe05e1da9585d0fb8be92151ca284cede15b3a6aa9bb442b9af324900
4
+ data.tar.gz: d658a121f536534d0208339e8734debf10c5b515a2d6a68d5dcbd2eddfcc5e42
5
5
  SHA512:
6
- metadata.gz: a3f334dcdf081777134219ab9f3c6ca0a0e95ca36495d71447690526c71bf893960219bda40d12c82973a2779131ff6977e99a141829f3a4121378b65d8e1659
7
- data.tar.gz: 8eb2229994c72de036a4cf5e865b2503efcb831dd12c1182e4b45d43956cc89ffecb44f2bb1b7fe7a5ab50b82f4a662ddf2f7bee3756cac054d75639c8c5a6e2
6
+ metadata.gz: '08e240f5d4a8a61f991e35b37a4bae4216bd0cc260f03f8af911219df8e73dc7c8c891d435e4a63b82bd5e2ce7dca476b3ba98634946d614e9bd387e2134bd7f'
7
+ data.tar.gz: 285ebd1cbce49cc3c17c8755bfc9775acedd7a098f0e69b7611faecd96b137dcd0f9f0e643a30a009af47ae3cc18bee1e2680670487ac42a4f5f378898059263
data/README.md CHANGED
@@ -142,11 +142,11 @@ end
142
142
 
143
143
  ### `measure_queries`
144
144
 
145
- This method displays query types executed when running a provided Ruby snippet, with their avg., min., max., and total duration. It also outputs info about the snippet execution duration and the portion spent running SQL queries (`total_duration`/`sql_duration`). It can help debug N+1 issues and review the impact of configuring eager loading:
145
+ This method displays query types executed when running a provided Ruby snippet, with their avg., min., max., and total duration in miliseconds. It also outputs info about the snippet execution duration and the portion spent running SQL queries (`total_duration`/`sql_duration`). It can help debug N+1 issues and review the impact of configuring eager loading:
146
146
 
147
147
  ```ruby
148
148
 
149
- User.measure_queries { User.limit(10).map(&:team) }
149
+ RailsPgExtras.measure_queries { User.limit(10).map(&:team) }
150
150
 
151
151
  # {:count=>11,
152
152
  # :queries=>
@@ -165,7 +165,7 @@ User.measure_queries { User.limit(10).map(&:team) }
165
165
  # :total_duration=>0.15247199998702854,
166
166
  # :sql_duration=>0.01486500003375113}
167
167
 
168
- User.measure_queries { User.limit(10).includes(:team).map(&:team) }
168
+ RailsPgExtras.measure_queries { User.limit(10).includes(:team).map(&:team) }
169
169
 
170
170
  # {:count=>2,
171
171
  # :queries=>
@@ -66,8 +66,7 @@ module RailsPgExtras
66
66
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
67
67
  block.call
68
68
  ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
69
- elapsed = ending - starting
70
- elapsed
69
+ (ending - starting) * 1000
71
70
  end
72
71
 
73
72
  def self.measure_queries(&block)
@@ -85,7 +84,7 @@ module RailsPgExtras
85
84
  key = payload[:sql]
86
85
  queries[key] ||= { count: 0, total_duration: 0, min_duration: nil, max_duration: nil }
87
86
  queries[key][:count] += 1
88
- duration = finish - start
87
+ duration = (finish - start) * 1000
89
88
  queries[key][:total_duration] += duration
90
89
  sql_duration += duration
91
90
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtras
4
- VERSION = "5.1.0"
4
+ VERSION = "5.2.0"
5
5
  end
data/spec/smoke_spec.rb CHANGED
@@ -30,7 +30,7 @@ describe RailsPgExtras do
30
30
  end
31
31
 
32
32
  it "collecting queries data works" do
33
- output = RailsPgExtras.queries_data { RailsPgExtras.diagnose(in_format: :hash) }
33
+ output = RailsPgExtras.measure_queries { RailsPgExtras.diagnose(in_format: :hash) }
34
34
  expect(output.fetch(:count)).to eq 10
35
35
  end
36
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-26 00:00:00.000000000 Z
11
+ date: 2023-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-pg-extras
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.0
19
+ version: 5.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.1.0
26
+ version: 5.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement