nice_http 1.7.4 → 1.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nice_http.rb +6 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6cc0148dc7594bc3d443b24bbcd4a6972acbe804de52fa7e049b484ed945205
|
4
|
+
data.tar.gz: 6cc846a88eb78c0d38a3f5078031f71d549f4f03bca00e07b1eb79ff72213130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7014a284a236a6505d377b97692f728c8a35085c5742f8dd3ae0a5cbcd4433e175b566792dc768961001560154a6d8e313dff0d8c085282188209e8bcfb69f3
|
7
|
+
data.tar.gz: '019cc47a19e62ecdc911208187e49a37547bb7e6be2d9e7f2ae9196bfc2ed4d129c505323f2ec353895fd616ee9b4c6a21a0ba37b93150d02b72cbd587597ce5'
|
data/lib/nice_http.rb
CHANGED
@@ -156,6 +156,7 @@ class NiceHttp
|
|
156
156
|
# @param state [Symbol] state of the name supplied to group your specific stats
|
157
157
|
# @param started [Time] when the process you want the stats started
|
158
158
|
# @param finished [Time] when the process you want the stats finished
|
159
|
+
# @param item [Object] (Optional) The item to be added to :items key to store all items in an array
|
159
160
|
#
|
160
161
|
# @example
|
161
162
|
# started = Time.now
|
@@ -167,9 +168,9 @@ class NiceHttp
|
|
167
168
|
# end
|
168
169
|
# NiceHttp.add_stats(:customer, :create, started, Time.now)
|
169
170
|
######################################################
|
170
|
-
def self.add_stats(name, state, started, finished)
|
171
|
+
def self.add_stats(name, state, started, finished, item=nil)
|
171
172
|
self.stats[:specific] ||= {}
|
172
|
-
self.stats[:specific][name] ||= { num: 0, time_elapsed: { total: 0, maximum: 0, minimum: 1000, average: 0 }
|
173
|
+
self.stats[:specific][name] ||= { num: 0, time_elapsed: { total: 0, maximum: 0, minimum: 1000, average: 0 }}
|
173
174
|
self.stats[:specific][name][:num] += 1
|
174
175
|
time_elapsed = self.stats[:specific][name][:time_elapsed]
|
175
176
|
time_elapsed[:total] += finished - started
|
@@ -177,13 +178,15 @@ class NiceHttp
|
|
177
178
|
time_elapsed[:minimum] = (finished - started) if time_elapsed[:minimum] > (finished - started)
|
178
179
|
time_elapsed[:average] = time_elapsed[:total] / self.stats[:specific][name][:num]
|
179
180
|
|
180
|
-
self.stats[:specific][name][state] ||= { num: 0, time_elapsed: { total: 0, maximum: 0, minimum: 1000, average: 0 } }
|
181
|
+
self.stats[:specific][name][state] ||= { num: 0, time_elapsed: { total: 0, maximum: 0, minimum: 1000, average: 0 }, items: [] }
|
181
182
|
self.stats[:specific][name][state][:num] += 1
|
183
|
+
self.stats[:specific][name][state][:items] << item unless item.nil? or self.stats[:specific][name][state][:items].include?(item)
|
182
184
|
time_elapsed = self.stats[:specific][name][state][:time_elapsed]
|
183
185
|
time_elapsed[:total] += finished - started
|
184
186
|
time_elapsed[:maximum] = (finished - started) if time_elapsed[:maximum] < (finished - started)
|
185
187
|
time_elapsed[:minimum] = (finished - started) if time_elapsed[:minimum] > (finished - started)
|
186
188
|
time_elapsed[:average] = time_elapsed[:total] / self.stats[:specific][name][state][:num]
|
189
|
+
|
187
190
|
end
|
188
191
|
|
189
192
|
######################################################
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nice_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nice_hash
|