rails-pg-extras 5.2.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2e57fcbe05e1da9585d0fb8be92151ca284cede15b3a6aa9bb442b9af324900
4
- data.tar.gz: d658a121f536534d0208339e8734debf10c5b515a2d6a68d5dcbd2eddfcc5e42
3
+ metadata.gz: 4bd83f21b85de2b816dc334b72ad1bd0dfcb0f13ea6946fec42ebb93f47ba876
4
+ data.tar.gz: 4e9e5b00cc7e07cf3baa1bc3e224fe8ab50510afa909b47e753873fb1e7a11e7
5
5
  SHA512:
6
- metadata.gz: '08e240f5d4a8a61f991e35b37a4bae4216bd0cc260f03f8af911219df8e73dc7c8c891d435e4a63b82bd5e2ce7dca476b3ba98634946d614e9bd387e2134bd7f'
7
- data.tar.gz: 285ebd1cbce49cc3c17c8755bfc9775acedd7a098f0e69b7611faecd96b137dcd0f9f0e643a30a009af47ae3cc18bee1e2680670487ac42a4f5f378898059263
6
+ metadata.gz: 1a30823d47f9e0cab719b7ee6e750da28c751f4dc20d21756f7f3a633c07dd6390397e09502300cfcf9185184a9e00af83de40f2fd9b12a6319a6ade31ccb26f
7
+ data.tar.gz: f01d58920638949122f26a74857cdab232168b274aee2d28d180eed09ea60a48ace036aa3ba772dc8ce41893d6e4a4397255167bc5ccf699a181c7205438ed93
data/README.md CHANGED
@@ -148,41 +148,41 @@ This method displays query types executed when running a provided Ruby snippet,
148
148
 
149
149
  RailsPgExtras.measure_queries { User.limit(10).map(&:team) }
150
150
 
151
- # {:count=>11,
152
- # :queries=>
153
- # {"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
154
- # {:count=>1,
155
- # :total_duration=>0.003183000022545457,
156
- # :min_duration=>0.003183000022545457,
157
- # :max_duration=>0.003183000022545457,
158
- # :avg_duration=>0.003183000022545457},
159
- # "SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" = $1 LIMIT $2"=>
160
- # {:count=>10,
161
- # :total_duration=>0.011682000011205673,
162
- # :min_duration=>0.0007209999894257635,
163
- # :max_duration=>0.0024030000204220414,
164
- # :avg_duration=>0.0011682000011205673}},
165
- # :total_duration=>0.15247199998702854,
166
- # :sql_duration=>0.01486500003375113}
151
+ {:count=>11,
152
+ :queries=>
153
+ {"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
154
+ {:count=>1,
155
+ :total_duration=>3.452000004472211,
156
+ :min_duration=>3.452000004472211,
157
+ :max_duration=>3.452000004472211,
158
+ :avg_duration=>3.452000004472211},
159
+ "SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" = $1 LIMIT $2"=>
160
+ {:count=>10,
161
+ :total_duration=>14.487000000372063,
162
+ :min_duration=>0.778000001446344,
163
+ :max_duration=>1.985000002605375,
164
+ :avg_duration=>1.4487000000372063}},
165
+ :total_duration=>24.812000003294088,
166
+ :sql_duration=>17.939000004844274}
167
167
 
168
168
  RailsPgExtras.measure_queries { User.limit(10).includes(:team).map(&:team) }
169
169
 
170
- # {:count=>2,
171
- # :queries=>
172
- # {"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
173
- # {:count=>1,
174
- # :total_duration=>0.0036189999955240637,
175
- # :min_duration=>0.0036189999955240637,
176
- # :max_duration=>0.0036189999955240637,
177
- # :avg_duration=>0.0036189999955240637},
178
- # "SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" IN ($1, $2, $3, $4, $5, $6, $7, $8)"=>
179
- # {:count=>1,
180
- # :total_duration=>0.003714999998919666,
181
- # :min_duration=>0.003714999998919666,
182
- # :max_duration=>0.003714999998919666,
183
- # :avg_duration=>0.003714999998919666}},
184
- # :total_duration=>0.023814999993192032,
185
- # :sql_duration=>0.0073339999944437295}
170
+ {:count=>2,
171
+ :queries=>
172
+ {"SELECT \"users\".* FROM \"users\" LIMIT $1"=>
173
+ {:count=>1,
174
+ :total_duration=>3.7079999965499155,
175
+ :min_duration=>3.7079999965499155,
176
+ :max_duration=>3.7079999965499155,
177
+ :avg_duration=>3.7079999965499155},
178
+ "SELECT \"teams\".* FROM \"teams\" WHERE \"teams\".\"id\" IN ($1, $2, $3, $4, $5, $6, $7, $8)"=>
179
+ {:count=>1,
180
+ :total_duration=>2.422000005026348,
181
+ :min_duration=>2.422000005026348,
182
+ :max_duration=>2.422000005026348,
183
+ :avg_duration=>2.422000005026348}},
184
+ :total_duration=>9.905999999318738,
185
+ :sql_duration=>6.1300000015762635}
186
186
 
187
187
  ```
188
188
 
@@ -89,11 +89,11 @@ module RailsPgExtras
89
89
  sql_duration += duration
90
90
 
91
91
  if queries[key][:min_duration] == nil || queries[key][:min_duration] > duration
92
- queries[key][:min_duration] = duration
92
+ queries[key][:min_duration] = duration.round(2)
93
93
  end
94
94
 
95
95
  if queries[key][:max_duration] == nil || queries[key][:max_duration] < duration
96
- queries[key][:max_duration] = duration
96
+ queries[key][:max_duration] = duration.round(2)
97
97
  end
98
98
  end
99
99
  end
@@ -103,7 +103,8 @@ module RailsPgExtras
103
103
  end
104
104
 
105
105
  queries = queries.reduce({}) do |agg, val|
106
- val[1][:avg_duration] = val[1][:total_duration] / val[1][:count]
106
+ val[1][:avg_duration] = (val[1][:total_duration] / val[1][:count]).round(2)
107
+ val[1][:total_duration] = val[1][:total_duration].round(2)
107
108
  agg.merge(val[0] => val[1])
108
109
  end
109
110
 
@@ -111,11 +112,12 @@ module RailsPgExtras
111
112
  {
112
113
  count: queries.reduce(0) { |agg, val| agg + val[1].fetch(:count) },
113
114
  queries: queries,
114
- total_duration: total_duration,
115
- sql_duration: sql_duration
115
+ total_duration: total_duration.round(2),
116
+ sql_duration: sql_duration.round(2)
116
117
  }
117
118
  end
118
119
 
120
+
119
121
  def self.index_info(args: {}, in_format: :display_table)
120
122
  data = RailsPgExtras::IndexInfo.call(args[:table_name])
121
123
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtras
4
- VERSION = "5.2.0"
4
+ VERSION = "5.2.1"
5
5
  end
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.2.0
4
+ version: 5.2.1
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-27 00:00:00.000000000 Z
11
+ date: 2023-03-01 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.2.0
19
+ version: 5.2.1
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.2.0
26
+ version: 5.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement