allq_rest 1.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 +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +111 -0
- data/Rakefile +8 -0
- data/allq_client-1.2.0.gem +0 -0
- data/allq_client.gemspec +46 -0
- data/allq_rest.gemspec +34 -0
- data/deploy.sh +3 -0
- data/docs/ActionsApi.md +544 -0
- data/docs/AdminApi.md +98 -0
- data/docs/BasicPayload.md +11 -0
- data/docs/BasicResponse.md +8 -0
- data/docs/JobRef.md +8 -0
- data/docs/JobResponse.md +12 -0
- data/docs/NewJob.md +13 -0
- data/docs/NewParentJob.md +16 -0
- data/docs/StatsInfo.md +9 -0
- data/docs/StatsResults.md +10 -0
- data/docs/StatsTube.md +14 -0
- data/docs/Throttle.md +9 -0
- data/docs/TubeRef.md +8 -0
- data/git_push.sh +55 -0
- data/lib/.DS_Store +0 -0
- data/lib/allq_client.rb +53 -0
- data/lib/allq_client/.DS_Store +0 -0
- data/lib/allq_client/api/actions_api.rb +702 -0
- data/lib/allq_client/api/admin_api.rb +181 -0
- data/lib/allq_client/api_client.rb +388 -0
- data/lib/allq_client/api_error.rb +38 -0
- data/lib/allq_client/configuration.rb +202 -0
- data/lib/allq_client/models/basic_payload.rb +218 -0
- data/lib/allq_client/models/basic_response.rb +188 -0
- data/lib/allq_client/models/job_ref.rb +190 -0
- data/lib/allq_client/models/job_response.rb +249 -0
- data/lib/allq_client/models/multiple_job_response.rb +187 -0
- data/lib/allq_client/models/new_job.rb +270 -0
- data/lib/allq_client/models/new_parent_job.rb +302 -0
- data/lib/allq_client/models/stats_info.rb +204 -0
- data/lib/allq_client/models/stats_results.rb +253 -0
- data/lib/allq_client/models/stats_tube.rb +285 -0
- data/lib/allq_client/models/throttle.rb +209 -0
- data/lib/allq_client/models/tube_ref.rb +190 -0
- data/lib/allq_client/version.rb +15 -0
- data/spec/.DS_Store +0 -0
- data/spec/api/actions_api_spec.rb +575 -0
- data/spec/api/admin_api_spec.rb +58 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/basic_payload_spec.rb +60 -0
- data/spec/models/basic_response_spec.rb +42 -0
- data/spec/models/job_ref_spec.rb +42 -0
- data/spec/models/job_response_spec.rb +66 -0
- data/spec/models/new_job_spec.rb +72 -0
- data/spec/models/new_parent_job_spec.rb +90 -0
- data/spec/models/stats_info_spec.rb +48 -0
- data/spec/models/stats_results_spec.rb +54 -0
- data/spec/models/stats_tube_spec.rb +78 -0
- data/spec/models/throttle_spec.rb +48 -0
- data/spec/models/tube_ref_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- metadata +299 -0
@@ -0,0 +1,209 @@
|
|
1
|
+
=begin
|
2
|
+
#AllQ
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Allq
|
16
|
+
# Throttle on tube
|
17
|
+
class Throttle
|
18
|
+
# Name of tube
|
19
|
+
attr_accessor :tube
|
20
|
+
|
21
|
+
# Transactions per second
|
22
|
+
attr_accessor :tps
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'tube' => :'tube',
|
28
|
+
:'tps' => :'tps'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.swagger_types
|
34
|
+
{
|
35
|
+
:'tube' => :'String',
|
36
|
+
:'tps' => :'Integer'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Initializes the object
|
41
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
42
|
+
def initialize(attributes = {})
|
43
|
+
return unless attributes.is_a?(Hash)
|
44
|
+
|
45
|
+
# convert string to symbol for hash key
|
46
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
47
|
+
|
48
|
+
if attributes.has_key?(:'tube')
|
49
|
+
self.tube = attributes[:'tube']
|
50
|
+
else
|
51
|
+
self.tube = 'default'
|
52
|
+
end
|
53
|
+
|
54
|
+
if attributes.has_key?(:'tps')
|
55
|
+
self.tps = attributes[:'tps']
|
56
|
+
else
|
57
|
+
self.tps = 1000
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
62
|
+
# @return Array for valid properties with the reasons
|
63
|
+
def list_invalid_properties
|
64
|
+
invalid_properties = Array.new
|
65
|
+
if @tube.nil?
|
66
|
+
invalid_properties.push('invalid value for "tube", tube cannot be nil.')
|
67
|
+
end
|
68
|
+
|
69
|
+
if @tps.nil?
|
70
|
+
invalid_properties.push('invalid value for "tps", tps cannot be nil.')
|
71
|
+
end
|
72
|
+
|
73
|
+
invalid_properties
|
74
|
+
end
|
75
|
+
|
76
|
+
# Check to see if the all the properties in the model are valid
|
77
|
+
# @return true if the model is valid
|
78
|
+
def valid?
|
79
|
+
return false if @tube.nil?
|
80
|
+
return false if @tps.nil?
|
81
|
+
true
|
82
|
+
end
|
83
|
+
|
84
|
+
# Checks equality by comparing each attribute.
|
85
|
+
# @param [Object] Object to be compared
|
86
|
+
def ==(o)
|
87
|
+
return true if self.equal?(o)
|
88
|
+
self.class == o.class &&
|
89
|
+
tube == o.tube &&
|
90
|
+
tps == o.tps
|
91
|
+
end
|
92
|
+
|
93
|
+
# @see the `==` method
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def eql?(o)
|
96
|
+
self == o
|
97
|
+
end
|
98
|
+
|
99
|
+
# Calculates hash code according to all attributes.
|
100
|
+
# @return [Fixnum] Hash code
|
101
|
+
def hash
|
102
|
+
[tube, tps].hash
|
103
|
+
end
|
104
|
+
|
105
|
+
# Builds the object from hash
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
# @return [Object] Returns the model itself
|
108
|
+
def build_from_hash(attributes)
|
109
|
+
return nil unless attributes.is_a?(Hash)
|
110
|
+
self.class.swagger_types.each_pair do |key, type|
|
111
|
+
if type =~ /\AArray<(.*)>/i
|
112
|
+
# check to ensure the input is an array given that the the attribute
|
113
|
+
# is documented as an array but the input is not
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
116
|
+
end
|
117
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
118
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
119
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
120
|
+
end
|
121
|
+
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Deserializes the data based on type
|
126
|
+
# @param string type Data type
|
127
|
+
# @param string value Value to be deserialized
|
128
|
+
# @return [Object] Deserialized data
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :BOOLEAN
|
142
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
temp_model = Allq.const_get(type).new
|
163
|
+
temp_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Returns the string representation of the object
|
168
|
+
# @return [String] String presentation of the object
|
169
|
+
def to_s
|
170
|
+
to_hash.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
# to_body is an alias to to_hash (backward compatibility)
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_body
|
176
|
+
to_hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the object in the form of hash
|
180
|
+
# @return [Hash] Returns the object in the form of hash
|
181
|
+
def to_hash
|
182
|
+
hash = {}
|
183
|
+
self.class.attribute_map.each_pair do |attr, param|
|
184
|
+
value = self.send(attr)
|
185
|
+
next if value.nil?
|
186
|
+
hash[param] = _to_hash(value)
|
187
|
+
end
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to? :to_hash
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
=begin
|
2
|
+
#AllQ
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Allq
|
16
|
+
# Name of tube
|
17
|
+
class TubeRef
|
18
|
+
# Name of tube
|
19
|
+
attr_accessor :tube
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'tube' => :'tube'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'tube' => :'String'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
42
|
+
|
43
|
+
if attributes.has_key?(:'tube')
|
44
|
+
self.tube = attributes[:'tube']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
49
|
+
# @return Array for valid properties with the reasons
|
50
|
+
def list_invalid_properties
|
51
|
+
invalid_properties = Array.new
|
52
|
+
if @tube.nil?
|
53
|
+
invalid_properties.push('invalid value for "tube", tube cannot be nil.')
|
54
|
+
end
|
55
|
+
|
56
|
+
invalid_properties
|
57
|
+
end
|
58
|
+
|
59
|
+
# Check to see if the all the properties in the model are valid
|
60
|
+
# @return true if the model is valid
|
61
|
+
def valid?
|
62
|
+
return false if @tube.nil?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(o)
|
69
|
+
return true if self.equal?(o)
|
70
|
+
self.class == o.class &&
|
71
|
+
tube == o.tube
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(o)
|
77
|
+
self == o
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Fixnum] Hash code
|
82
|
+
def hash
|
83
|
+
[tube].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
self.class.swagger_types.each_pair do |key, type|
|
92
|
+
if type =~ /\AArray<(.*)>/i
|
93
|
+
# check to ensure the input is an array given that the the attribute
|
94
|
+
# is documented as an array but the input is not
|
95
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
96
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
97
|
+
end
|
98
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
99
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
100
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
101
|
+
end
|
102
|
+
|
103
|
+
self
|
104
|
+
end
|
105
|
+
|
106
|
+
# Deserializes the data based on type
|
107
|
+
# @param string type Data type
|
108
|
+
# @param string value Value to be deserialized
|
109
|
+
# @return [Object] Deserialized data
|
110
|
+
def _deserialize(type, value)
|
111
|
+
case type.to_sym
|
112
|
+
when :DateTime
|
113
|
+
DateTime.parse(value)
|
114
|
+
when :Date
|
115
|
+
Date.parse(value)
|
116
|
+
when :String
|
117
|
+
value.to_s
|
118
|
+
when :Integer
|
119
|
+
value.to_i
|
120
|
+
when :Float
|
121
|
+
value.to_f
|
122
|
+
when :BOOLEAN
|
123
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
124
|
+
true
|
125
|
+
else
|
126
|
+
false
|
127
|
+
end
|
128
|
+
when :Object
|
129
|
+
# generic object (usually a Hash), return directly
|
130
|
+
value
|
131
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
132
|
+
inner_type = Regexp.last_match[:inner_type]
|
133
|
+
value.map { |v| _deserialize(inner_type, v) }
|
134
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
135
|
+
k_type = Regexp.last_match[:k_type]
|
136
|
+
v_type = Regexp.last_match[:v_type]
|
137
|
+
{}.tap do |hash|
|
138
|
+
value.each do |k, v|
|
139
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
else # model
|
143
|
+
temp_model = Allq.const_get(type).new
|
144
|
+
temp_model.build_from_hash(value)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns the string representation of the object
|
149
|
+
# @return [String] String presentation of the object
|
150
|
+
def to_s
|
151
|
+
to_hash.to_s
|
152
|
+
end
|
153
|
+
|
154
|
+
# to_body is an alias to to_hash (backward compatibility)
|
155
|
+
# @return [Hash] Returns the object in the form of hash
|
156
|
+
def to_body
|
157
|
+
to_hash
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the object in the form of hash
|
161
|
+
# @return [Hash] Returns the object in the form of hash
|
162
|
+
def to_hash
|
163
|
+
hash = {}
|
164
|
+
self.class.attribute_map.each_pair do |attr, param|
|
165
|
+
value = self.send(attr)
|
166
|
+
next if value.nil?
|
167
|
+
hash[param] = _to_hash(value)
|
168
|
+
end
|
169
|
+
hash
|
170
|
+
end
|
171
|
+
|
172
|
+
# Outputs non-array value in the form of hash
|
173
|
+
# For object, use to_hash. Otherwise, just return the value
|
174
|
+
# @param [Object] value Any valid value
|
175
|
+
# @return [Hash] Returns the value in the form of hash
|
176
|
+
def _to_hash(value)
|
177
|
+
if value.is_a?(Array)
|
178
|
+
value.compact.map { |v| _to_hash(v) }
|
179
|
+
elsif value.is_a?(Hash)
|
180
|
+
{}.tap do |hash|
|
181
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
182
|
+
end
|
183
|
+
elsif value.respond_to? :to_hash
|
184
|
+
value.to_hash
|
185
|
+
else
|
186
|
+
value
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
=begin
|
2
|
+
#AllQ
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
module Allq
|
14
|
+
VERSION = '1.2.0'
|
15
|
+
end
|
data/spec/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,575 @@
|
|
1
|
+
=begin
|
2
|
+
#AllQ
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'spec_helper'
|
14
|
+
require 'json'
|
15
|
+
|
16
|
+
DEFAULT_TUBE = "default"
|
17
|
+
ALT_TUBE = ""
|
18
|
+
# Unit tests for Allq::ActionsApi
|
19
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
20
|
+
# Please update as you see appropriate
|
21
|
+
describe 'ActionsApi' do
|
22
|
+
before do
|
23
|
+
# run before each test
|
24
|
+
@instance = Allq::ActionsApi.new
|
25
|
+
stats_result = AllQTools::get_stats[0]
|
26
|
+
stats_result.stats.each do |stat|
|
27
|
+
@instance.tube_delete(stat.tube)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
# run after each test
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'test an instance of ActionsApi' do
|
36
|
+
it 'should create an instance of ActionsApi' do
|
37
|
+
expect(@instance).to be_instance_of(Allq::ActionsApi)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# unit tests for bury_put
|
42
|
+
# Bury
|
43
|
+
# Bury Job
|
44
|
+
# @param job_id Job ID
|
45
|
+
# @param [Hash] opts the optional parameters
|
46
|
+
# @return [BasicResponse]
|
47
|
+
describe 'bury_put test' do
|
48
|
+
it "should work" do
|
49
|
+
AllQTools::add_job
|
50
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
51
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
52
|
+
@instance.bury_put(job.id)
|
53
|
+
expect(AllQTools::get_buried(DEFAULT_TUBE)).to eq(1)
|
54
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# unit tests for job_delete
|
59
|
+
# Delete
|
60
|
+
# Finished Job
|
61
|
+
# @param job_id Job ID
|
62
|
+
# @param [Hash] opts the optional parameters
|
63
|
+
# @option opts [String] :tube Name of Tube (For deleting \"ready\" objects)
|
64
|
+
# @return [BasicResponse]
|
65
|
+
describe 'job_delete test' do
|
66
|
+
it "should work" do
|
67
|
+
AllQTools::add_job
|
68
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
69
|
+
job = @instance.peek_get(DEFAULT_TUBE)
|
70
|
+
@instance.job_delete(job.id, tube: DEFAULT_TUBE)
|
71
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# unit tests for job_get
|
76
|
+
# Job
|
77
|
+
# Get job from queue
|
78
|
+
# @param tube Name of tube
|
79
|
+
# @param [Hash] opts the optional parameters
|
80
|
+
# @return [JobResponse]
|
81
|
+
describe 'job_get test' do
|
82
|
+
it "should work" do
|
83
|
+
AllQTools::add_job
|
84
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
85
|
+
expect(AllQTools::get_reserved(DEFAULT_TUBE)).to eq(1)
|
86
|
+
expect(job.id).to be_truthy
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# unit tests for multiple job_get
|
91
|
+
# Job
|
92
|
+
# Get job from queue
|
93
|
+
# @param tube Name of tube
|
94
|
+
# @param [Hash] opts the optional parameters
|
95
|
+
# @return [JobResponse]
|
96
|
+
describe 'mulitple_job_get test' do
|
97
|
+
it "should work" do
|
98
|
+
1.upto(6) do
|
99
|
+
AllQTools::add_job
|
100
|
+
end
|
101
|
+
multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
|
102
|
+
expect(multiple_jobs.jobs.length).to eq(4)
|
103
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(2)
|
104
|
+
multiple_jobs.jobs.each do |job|
|
105
|
+
@instance.job_delete(job.id)
|
106
|
+
end
|
107
|
+
expect(AllQTools::get_reserved(DEFAULT_TUBE)).to eq(0)
|
108
|
+
|
109
|
+
multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
|
110
|
+
expect(multiple_jobs.jobs.length).to eq(2)
|
111
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# unit tests for job_post
|
116
|
+
# Job
|
117
|
+
# Put job into queue
|
118
|
+
# @param new_job New Job Object
|
119
|
+
# @param [Hash] opts the optional parameters
|
120
|
+
# @return [JobRef]
|
121
|
+
describe 'job_post test' do
|
122
|
+
it "should work" do
|
123
|
+
AllQTools::add_job
|
124
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
125
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
126
|
+
expect(job.id).to be_truthy
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# unit tests for parent_job_post
|
131
|
+
# Parent Job
|
132
|
+
# Create a parent job
|
133
|
+
# @param new_parent_job New Parent Job Data
|
134
|
+
# @param [Hash] opts the optional parameters
|
135
|
+
# @return [JobRef]
|
136
|
+
describe 'parent_job_post test' do
|
137
|
+
it "should work" do
|
138
|
+
new_parent_job = Allq::NewParentJob.new(tube: 'default',
|
139
|
+
body: '<PARENT_BODY>',
|
140
|
+
ttl: 1200,
|
141
|
+
delay: 0,
|
142
|
+
priority: 5,
|
143
|
+
timeout: 1000,
|
144
|
+
run_on_timeout: false,
|
145
|
+
limit: 2)
|
146
|
+
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
147
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
148
|
+
job = AllQTools::new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
149
|
+
@instance.job_post(job)
|
150
|
+
job = AllQTools::new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
151
|
+
@instance.job_post(job)
|
152
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(2)
|
153
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
154
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
155
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
156
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(0)
|
157
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
158
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# unit tests for parent_job_post
|
163
|
+
# Parent Job
|
164
|
+
# Create a parent job
|
165
|
+
# @param new_parent_job New Parent Job Data
|
166
|
+
# @param [Hash] opts the optional parameters
|
167
|
+
# @return [JobRef]
|
168
|
+
describe 'parent_job_post test with different tubes' do
|
169
|
+
it "should work" do
|
170
|
+
new_parent_job = Allq::NewParentJob.new(tube: 'default',
|
171
|
+
body: '<PARENT_BODY>',
|
172
|
+
ttl: 1200,
|
173
|
+
delay: 0,
|
174
|
+
priority: 5,
|
175
|
+
timeout: 1000,
|
176
|
+
run_on_timeout: false,
|
177
|
+
limit: 2)
|
178
|
+
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
179
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
180
|
+
|
181
|
+
job = AllQTools::new_job('foo', nil, new_parent_job_response.job_id)
|
182
|
+
@instance.job_post(job)
|
183
|
+
job = AllQTools::new_job('foo', nil, new_parent_job_response.job_id)
|
184
|
+
@instance.job_post(job)
|
185
|
+
expect(AllQTools::get_ready('foo')).to eq(2)
|
186
|
+
AllQTools::get_finish('foo')
|
187
|
+
AllQTools::get_finish('foo')
|
188
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
189
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(0)
|
190
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
191
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# unit tests for parent_job_post
|
196
|
+
# Parent Job
|
197
|
+
# Create a parent job
|
198
|
+
# @param new_parent_job New Parent Job Data
|
199
|
+
# @param [Hash] opts the optional parameters
|
200
|
+
# @return [JobRef]
|
201
|
+
describe 'parent_job_post should timeout if child not completed in time' do
|
202
|
+
fit "should work" do
|
203
|
+
new_parent_job = Allq::NewParentJob.new(tube: 'default',
|
204
|
+
body: '<PARENT_BODY>',
|
205
|
+
ttl: 1200,
|
206
|
+
delay: 0,
|
207
|
+
priority: 5,
|
208
|
+
timeout: 2,
|
209
|
+
run_on_timeout: true,
|
210
|
+
limit: 2)
|
211
|
+
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
212
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
213
|
+
|
214
|
+
job = AllQTools::new_job('foo', nil, new_parent_job_response.job_id)
|
215
|
+
@instance.job_post(job)
|
216
|
+
expect(AllQTools::get_ready('foo')).to eq(1)
|
217
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
218
|
+
|
219
|
+
sleep(7)
|
220
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(0)
|
221
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
# unit tests for peek_get
|
226
|
+
# Peek
|
227
|
+
# Peek at next job
|
228
|
+
# @param tube Tube name
|
229
|
+
# @param [Hash] opts the optional parameters
|
230
|
+
# @option opts [String] :buried Look in buried
|
231
|
+
# @return [JobResponse]
|
232
|
+
describe 'peek_get test' do
|
233
|
+
it "should work" do
|
234
|
+
AllQTools::add_job
|
235
|
+
job = @instance.peek_get(DEFAULT_TUBE)
|
236
|
+
expect(job.id).to be_truthy
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
describe 'peek_get buried test' do
|
241
|
+
it "should work" do
|
242
|
+
AllQTools::add_job
|
243
|
+
job = @instance.peek_get(DEFAULT_TUBE, buried: true)
|
244
|
+
expect(job.id).to be_falsey
|
245
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
246
|
+
@instance.bury_put(job.id)
|
247
|
+
job = @instance.peek_get(DEFAULT_TUBE, buried: true)
|
248
|
+
expect(job.id).to be_truthy
|
249
|
+
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
# unit tests for peek_get
|
254
|
+
# Peek
|
255
|
+
# Peek at next job
|
256
|
+
# @param tube Tube name
|
257
|
+
# @param [Hash] opts the optional parameters
|
258
|
+
# @option opts [String] :buried Look in buried
|
259
|
+
# @return [JobResponse]
|
260
|
+
describe 'peek_get test(no jobs)' do
|
261
|
+
it "should work" do
|
262
|
+
job = @instance.peek_get(DEFAULT_TUBE)
|
263
|
+
expect(job.id).to be_falsey
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
# unit tests for release_put
|
268
|
+
# Release
|
269
|
+
# Releases job back into queue
|
270
|
+
# @param job_id Job ID
|
271
|
+
# @param [Hash] opts the optional parameters
|
272
|
+
# @return [BasicResponse]
|
273
|
+
describe 'release_put test' do
|
274
|
+
it "should work" do
|
275
|
+
AllQTools::add_job
|
276
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
277
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
278
|
+
expect(AllQTools::get_reserved(DEFAULT_TUBE)).to eq(1)
|
279
|
+
expect(job.id).to be_truthy
|
280
|
+
@instance.release_put(job.id)
|
281
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe 'release should increment release' do
|
286
|
+
it "should work" do
|
287
|
+
AllQTools::add_job
|
288
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
289
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
290
|
+
expect(job.releases).to eq(0)
|
291
|
+
@instance.release_put(job.id)
|
292
|
+
sleep(1)
|
293
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
294
|
+
expect(job.releases).to eq(1)
|
295
|
+
@instance.release_put(job.id)
|
296
|
+
sleep(1)
|
297
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
298
|
+
expect(job.releases).to eq(2)
|
299
|
+
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# unit tests for set_children_started_put
|
304
|
+
# Set Children Started
|
305
|
+
# When a parent job doesn't know how many children are going to be added, this is the event that sets the final children count on the parent_job, allowing it to run when the children are done.
|
306
|
+
# @param job_id Job ID
|
307
|
+
# @param [Hash] opts the optional parameters
|
308
|
+
# @return [BasicResponse]
|
309
|
+
describe 'set_children_started_put test' do
|
310
|
+
it "should work" do
|
311
|
+
new_parent_job = Allq::NewParentJob.new(tube: 'default',
|
312
|
+
body: '<PARENT_BODY>',
|
313
|
+
ttl: 1200,
|
314
|
+
delay: 0,
|
315
|
+
priority: 5,
|
316
|
+
timeout: 1000,
|
317
|
+
run_on_timeout: false,
|
318
|
+
limit: nil)
|
319
|
+
new_parent_job_response = @instance.parent_job_post(new_parent_job)
|
320
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
321
|
+
job = AllQTools::new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
322
|
+
@instance.job_post(job)
|
323
|
+
job = AllQTools::new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
|
324
|
+
@instance.job_post(job)
|
325
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(2)
|
326
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
327
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
328
|
+
# After jobs have already finished
|
329
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
330
|
+
# Parent still waiting
|
331
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(1)
|
332
|
+
# Set limit on parent
|
333
|
+
@instance.set_children_started_put(new_parent_job_response.job_id)
|
334
|
+
# Now parent gets moved to ready
|
335
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
336
|
+
expect(AllQTools::get_parents(DEFAULT_TUBE)).to eq(0)
|
337
|
+
AllQTools::get_finish(DEFAULT_TUBE)
|
338
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
# unit tests for throttle_post
|
343
|
+
# Throttle
|
344
|
+
# Creates a throttle on a tube
|
345
|
+
# @param throttle Throttle info
|
346
|
+
# @param [Hash] opts the optional parameters
|
347
|
+
# @return [TubeRef]
|
348
|
+
describe 'throttle_post test' do
|
349
|
+
it "should work" do
|
350
|
+
throttle = Allq::Throttle.new(tps: 5, tube: "throttled")
|
351
|
+
@instance.throttle_post(throttle)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
355
|
+
# unit tests for stats
|
356
|
+
# Stats Action Count
|
357
|
+
# Checks action count
|
358
|
+
# @param throttle Throttle info
|
359
|
+
# @param [Hash] opts the optional parameters
|
360
|
+
# @return [TubeRef]
|
361
|
+
describe 'throttle_post test' do
|
362
|
+
it "should work" do
|
363
|
+
AllQTools::add_job
|
364
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
365
|
+
@instance.job_get(DEFAULT_TUBE)
|
366
|
+
stats_result = AllQTools::get_stats[0]
|
367
|
+
expect(stats_result.action_count > 1).to eq(true)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
# unit tests for touch_put
|
372
|
+
# Touch
|
373
|
+
# Touch job
|
374
|
+
# @param job_id Job ID
|
375
|
+
# @param [Hash] opts the optional parameters
|
376
|
+
# @return [BasicResponse]
|
377
|
+
describe 'touch_put test' do
|
378
|
+
it "should work" do
|
379
|
+
AllQTools::add_job
|
380
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1)
|
381
|
+
job = @instance.job_get(DEFAULT_TUBE)
|
382
|
+
@instance.touch_put(job.id)
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# unit tests for tube_delete
|
387
|
+
# Clear Tube
|
388
|
+
# Delete all contents of tube
|
389
|
+
# @param tube Tube Name
|
390
|
+
# @param [Hash] opts the optional parameters
|
391
|
+
# @return [BasicResponse]
|
392
|
+
describe 'tube_delete test' do
|
393
|
+
it "should work" do
|
394
|
+
alt_tube_name = "alt_tube"
|
395
|
+
new_job = Allq::NewJob.new(tube: alt_tube_name,
|
396
|
+
body: "Some body",
|
397
|
+
ttl: 1200,
|
398
|
+
delay: 0,
|
399
|
+
priority: 5,
|
400
|
+
parent_id: nil)
|
401
|
+
@instance.job_post(new_job)
|
402
|
+
new_job = Allq::NewJob.new(tube: alt_tube_name,
|
403
|
+
body: "Some body",
|
404
|
+
ttl: 1200,
|
405
|
+
delay: 0,
|
406
|
+
priority: 5,
|
407
|
+
parent_id: nil)
|
408
|
+
@instance.job_post(new_job)
|
409
|
+
new_job = Allq::NewJob.new(tube: alt_tube_name,
|
410
|
+
body: "Some body",
|
411
|
+
ttl: 1200,
|
412
|
+
delay: 0,
|
413
|
+
priority: 5,
|
414
|
+
parent_id: nil)
|
415
|
+
@instance.job_post(new_job)
|
416
|
+
new_job = Allq::NewJob.new(tube: "alt_tube2",
|
417
|
+
body: "Some body",
|
418
|
+
ttl: 1200,
|
419
|
+
delay: 0,
|
420
|
+
priority: 5,
|
421
|
+
parent_id: nil)
|
422
|
+
@instance.job_post(new_job)
|
423
|
+
new_job = Allq::NewJob.new(tube: "alt_tube2",
|
424
|
+
body: "Some body",
|
425
|
+
ttl: 1200,
|
426
|
+
delay: 0,
|
427
|
+
priority: 5,
|
428
|
+
parent_id: nil)
|
429
|
+
@instance.job_post(new_job)
|
430
|
+
expect(AllQTools::get_ready("alt_tube2")).to eq(2) # OK..it's there
|
431
|
+
reserved_job = @instance.job_get("alt_tube2")
|
432
|
+
|
433
|
+
# Other tube has 1 ready, 1 reserved
|
434
|
+
expect(AllQTools::get_ready("alt_tube2")).to eq(1)
|
435
|
+
expect(AllQTools::get_reserved("alt_tube2")).to eq(1)
|
436
|
+
|
437
|
+
# Get 1 into buried, 1 into reserved, and 1 in ready so we can clear it
|
438
|
+
expect(AllQTools::get_ready(alt_tube_name)).to eq(3) # OK..it's there
|
439
|
+
reserved_job = @instance.job_get(alt_tube_name)
|
440
|
+
expect(AllQTools::get_reserved(alt_tube_name)).to eq(1) # OK..it's there
|
441
|
+
reserved_job = @instance.job_get(alt_tube_name)
|
442
|
+
expect(AllQTools::get_reserved(alt_tube_name)).to eq(2) # OK..it's there
|
443
|
+
@instance.bury_put(reserved_job.id)
|
444
|
+
expect(AllQTools::get_buried(alt_tube_name)).to eq(1)
|
445
|
+
|
446
|
+
# Now check that first tube is empty
|
447
|
+
@instance.tube_delete(alt_tube_name)
|
448
|
+
expect(AllQTools::get_buried(alt_tube_name)).to eq(0)
|
449
|
+
expect(AllQTools::get_reserved(alt_tube_name)).to eq(0) # OK..it's there
|
450
|
+
expect(AllQTools::get_ready(alt_tube_name)).to eq(0)
|
451
|
+
|
452
|
+
# ..and other tubes are fine
|
453
|
+
expect(AllQTools::get_ready("alt_tube2")).to eq(1)
|
454
|
+
expect(AllQTools::get_reserved("alt_tube2")).to eq(1)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
# unit tests for delay
|
459
|
+
# Delay
|
460
|
+
describe 'delay test' do
|
461
|
+
it "should work" do
|
462
|
+
new_job = Allq::NewJob.new(tube: DEFAULT_TUBE,
|
463
|
+
body: "Some body",
|
464
|
+
ttl: 1200,
|
465
|
+
delay: 1,
|
466
|
+
priority: 5,
|
467
|
+
parent_id: nil)
|
468
|
+
@instance.job_post(new_job)
|
469
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(0) # Too soon to show up
|
470
|
+
sleep(4)
|
471
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1) # OK..it's there
|
472
|
+
end
|
473
|
+
end
|
474
|
+
|
475
|
+
# unit tests for expire
|
476
|
+
# Expire
|
477
|
+
describe 'expire test' do
|
478
|
+
it "should work" do
|
479
|
+
new_job = Allq::NewJob.new(tube: DEFAULT_TUBE,
|
480
|
+
body: "Some body",
|
481
|
+
ttl: 1,
|
482
|
+
delay: 0,
|
483
|
+
priority: 5,
|
484
|
+
parent_id: nil)
|
485
|
+
@instance.job_post(new_job)
|
486
|
+
sleep(1)
|
487
|
+
@instance.job_get(DEFAULT_TUBE)
|
488
|
+
expect(AllQTools::get_reserved(DEFAULT_TUBE)).to eq(1)
|
489
|
+
sleep(5)
|
490
|
+
expect(AllQTools::get_reserved(DEFAULT_TUBE)).to eq(0) # Should expire
|
491
|
+
expect(AllQTools::get_ready(DEFAULT_TUBE)).to eq(1) # ..and be back in ready
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
end
|
496
|
+
|
497
|
+
|
498
|
+
module AllQTools
|
499
|
+
class << self
|
500
|
+
|
501
|
+
def new_job(tube = 'default', body = nil, parent_id = nil)
|
502
|
+
body = (0...8).map { (65 + rand(26)).chr }.join unless body
|
503
|
+
|
504
|
+
new_job = Allq::NewJob.new(tube: tube,
|
505
|
+
body: body,
|
506
|
+
ttl: 1200,
|
507
|
+
delay: 0,
|
508
|
+
priority: 5,
|
509
|
+
parent_id:parent_id)
|
510
|
+
return new_job
|
511
|
+
end
|
512
|
+
|
513
|
+
def add_job(tube = DEFAULT_TUBE)
|
514
|
+
client = Allq::ActionsApi.new
|
515
|
+
job = new_job(tube)
|
516
|
+
job = client.job_post(new_job)
|
517
|
+
return job
|
518
|
+
end
|
519
|
+
|
520
|
+
def get_finish(tube)
|
521
|
+
client = Allq::ActionsApi.new
|
522
|
+
job = client.job_get(tube)
|
523
|
+
client.job_delete(job.id)
|
524
|
+
end
|
525
|
+
|
526
|
+
def get_stats
|
527
|
+
client = Allq::AdminApi.new
|
528
|
+
client.stats_get
|
529
|
+
end
|
530
|
+
|
531
|
+
def get_ready(tube)
|
532
|
+
stats = get_stats
|
533
|
+
count = 0
|
534
|
+
find_tueq(stats, tube) do |found_stat|
|
535
|
+
count += found_stat.ready.to_i
|
536
|
+
end
|
537
|
+
return count
|
538
|
+
end
|
539
|
+
|
540
|
+
def get_reserved(tube)
|
541
|
+
stats = get_stats
|
542
|
+
count = 0
|
543
|
+
find_tueq(stats, tube) do |found_stat|
|
544
|
+
count += found_stat.reserved.to_i
|
545
|
+
end
|
546
|
+
return count
|
547
|
+
end
|
548
|
+
|
549
|
+
def get_buried(tube)
|
550
|
+
stats = get_stats
|
551
|
+
count = 0
|
552
|
+
find_tueq(stats, tube) do |found_stat|
|
553
|
+
count += found_stat.buried.to_i
|
554
|
+
end
|
555
|
+
return count
|
556
|
+
end
|
557
|
+
|
558
|
+
def get_parents(tube)
|
559
|
+
stats = get_stats
|
560
|
+
count = 0
|
561
|
+
find_tueq(stats, tube) do |found_stat|
|
562
|
+
count += found_stat.parents.to_i
|
563
|
+
end
|
564
|
+
return count
|
565
|
+
end
|
566
|
+
|
567
|
+
def find_tueq(all_stats, tube)
|
568
|
+
all_stats.each do |server_stat|
|
569
|
+
server_stat.stats.each do |stat|
|
570
|
+
yield stat if stat.tube == tube
|
571
|
+
end
|
572
|
+
end
|
573
|
+
end
|
574
|
+
end
|
575
|
+
end
|