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 +4 -4
- data/README.md +32 -32
- data/lib/rails-pg-extras.rb +7 -5
- data/lib/rails_pg_extras/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd83f21b85de2b816dc334b72ad1bd0dfcb0f13ea6946fec42ebb93f47ba876
|
4
|
+
data.tar.gz: 4e9e5b00cc7e07cf3baa1bc3e224fe8ab50510afa909b47e753873fb1e7a11e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
|
data/lib/rails-pg-extras.rb
CHANGED
@@ -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
|
|
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.
|
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-
|
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.
|
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.
|
26
|
+
version: 5.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|