fbe 0.32.0 → 0.33.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 +4 -4
- data/Gemfile.lock +4 -4
- data/lib/fbe/conclude.rb +6 -10
- data/lib/fbe/iterate.rb +24 -16
- data/lib/fbe.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '05709f3a8b84855b1cb59a586eb4ae7a83f2f87bf0d8490d14a4b59659513cd6'
|
4
|
+
data.tar.gz: 54da9a5a7e9d638859cfdb0b7c9b192673fdb2ede19ae4e3afecdbcf1164db36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab66f21e8f0f80070e3a8908fade06c2088659660d6d9aa127f6bc86e555b3efc4d3542aae40cfd301e2caa0af80a9227b02aaac5ce7e562ec346dad85d06ecf
|
7
|
+
data.tar.gz: e381efafdacff36bf1119f0075c18f558af4531a17a4e2ad9d15663f330bca2da7cde3c0862d2d98db5ee6bbe28e12d41c8617bd923b334c5b833befbfe8dcbb
|
data/Gemfile.lock
CHANGED
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
tago (~> 0.0)
|
61
61
|
typhoeus (~> 1.4)
|
62
62
|
benchmark (0.4.1)
|
63
|
-
bigdecimal (3.2.
|
63
|
+
bigdecimal (3.2.3)
|
64
64
|
builder (3.3.0)
|
65
65
|
concurrent-ruby (1.3.5)
|
66
66
|
connection_pool (2.5.4)
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
ellipsized (0.3.0)
|
77
77
|
ethon (0.15.0)
|
78
78
|
ffi (>= 1.15.0)
|
79
|
-
factbase (0.
|
79
|
+
factbase (0.16.1)
|
80
80
|
backtrace (~> 0.4)
|
81
81
|
decoor (~> 0.1)
|
82
82
|
ellipsized (~> 0.3)
|
@@ -114,7 +114,7 @@ GEM
|
|
114
114
|
graphql-client (0.26.0)
|
115
115
|
activesupport (>= 3.0)
|
116
116
|
graphql (>= 1.13.0)
|
117
|
-
hashdiff (1.2.
|
117
|
+
hashdiff (1.2.1)
|
118
118
|
i18n (1.14.7)
|
119
119
|
concurrent-ruby (~> 1.0)
|
120
120
|
intercepted (0.2.0)
|
@@ -233,7 +233,7 @@ GEM
|
|
233
233
|
sqlite3 (2.7.3-x86_64-darwin)
|
234
234
|
sqlite3 (2.7.3-x86_64-linux-gnu)
|
235
235
|
strscan (3.1.5)
|
236
|
-
tago (0.
|
236
|
+
tago (0.2.0)
|
237
237
|
timeout (0.4.3)
|
238
238
|
total (0.4.1)
|
239
239
|
typhoeus (1.5.0)
|
data/lib/fbe/conclude.rb
CHANGED
@@ -19,14 +19,14 @@ require_relative 'octo'
|
|
19
19
|
# @yield [Factbase::Fact] The fact
|
20
20
|
def Fbe.conclude(
|
21
21
|
fb: Fbe.fb, judge: $judge, loog: $loog, options: $options, global: $global,
|
22
|
-
start: $start,
|
22
|
+
start: $start, &
|
23
23
|
)
|
24
24
|
raise 'The fb is nil' if fb.nil?
|
25
25
|
raise 'The $judge is not set' if judge.nil?
|
26
26
|
raise 'The $global is not set' if global.nil?
|
27
27
|
raise 'The $options is not set' if options.nil?
|
28
28
|
raise 'The $loog is not set' if loog.nil?
|
29
|
-
c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:, start
|
29
|
+
c = Fbe::Conclude.new(fb:, judge:, loog:, options:, global:, start:)
|
30
30
|
c.instance_eval(&)
|
31
31
|
end
|
32
32
|
|
@@ -61,8 +61,7 @@ class Fbe::Conclude
|
|
61
61
|
# @param [Hash] global The hash for global caching
|
62
62
|
# @param [Judges::Options] options The options coming from the +judges+ tool
|
63
63
|
# @param [Loog] loog The logging facility
|
64
|
-
|
65
|
-
def initialize(fb:, judge:, global:, options:, loog:, start:, time: Time)
|
64
|
+
def initialize(fb:, judge:, global:, options:, loog:, start:)
|
66
65
|
@fb = fb
|
67
66
|
@judge = judge
|
68
67
|
@loog = loog
|
@@ -74,7 +73,6 @@ class Fbe::Conclude
|
|
74
73
|
@lifetime_aware = true
|
75
74
|
@quota_aware = true
|
76
75
|
@timeout = 60
|
77
|
-
@time = time
|
78
76
|
end
|
79
77
|
|
80
78
|
# Make this block not aware of GitHub API quota.
|
@@ -92,7 +90,7 @@ class Fbe::Conclude
|
|
92
90
|
# When the lifetime is over, the loop will NOT gracefully stop.
|
93
91
|
#
|
94
92
|
# @return [nil] Nothing is returned
|
95
|
-
def
|
93
|
+
def lifetime_unaware
|
96
94
|
@lifetime_aware = false
|
97
95
|
end
|
98
96
|
|
@@ -195,7 +193,6 @@ class Fbe::Conclude
|
|
195
193
|
# end
|
196
194
|
def roll(&)
|
197
195
|
passed = 0
|
198
|
-
start = @time.now
|
199
196
|
oct = Fbe.octo(loog: @loog, options: @options, global: @global)
|
200
197
|
@fb.query(@query).each do |a|
|
201
198
|
if @quota_aware && oct.off_quota?
|
@@ -206,9 +203,8 @@ class Fbe::Conclude
|
|
206
203
|
@loog.debug('We ran out of lifetime, must stop here')
|
207
204
|
break
|
208
205
|
end
|
209
|
-
now
|
210
|
-
|
211
|
-
@loog.debug("We've spent more than #{start.ago}, must stop here")
|
206
|
+
if Time.now > @start + @timeout
|
207
|
+
@loog.debug("We've spent more than #{@start.ago}, must stop here")
|
212
208
|
break
|
213
209
|
end
|
214
210
|
@fb.txn do |fbt|
|
data/lib/fbe/iterate.rb
CHANGED
@@ -37,12 +37,12 @@ require_relative 'unmask_repos'
|
|
37
37
|
# issue_id + 1
|
38
38
|
# end
|
39
39
|
# end
|
40
|
-
def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, &)
|
40
|
+
def Fbe.iterate(fb: Fbe.fb, loog: $loog, options: $options, global: $global, start: $start, &)
|
41
41
|
raise 'The fb is nil' if fb.nil?
|
42
42
|
raise 'The $global is not set' if global.nil?
|
43
43
|
raise 'The $options is not set' if options.nil?
|
44
44
|
raise 'The $loog is not set' if loog.nil?
|
45
|
-
c = Fbe::Iterate.new(fb:, loog:, options:, global:)
|
45
|
+
c = Fbe::Iterate.new(fb:, loog:, options:, global:, start:)
|
46
46
|
c.instance_eval(&)
|
47
47
|
end
|
48
48
|
|
@@ -84,16 +84,18 @@ class Fbe::Iterate
|
|
84
84
|
# @param [Loog] loog The logging facility for debug output
|
85
85
|
# @param [Judges::Options] options The options containing repository configuration
|
86
86
|
# @param [Hash] global The hash for global caching of API responses
|
87
|
-
def initialize(fb:, loog:, options:, global:)
|
87
|
+
def initialize(fb:, loog:, options:, global:, start:)
|
88
88
|
@fb = fb
|
89
89
|
@loog = loog
|
90
90
|
@options = options
|
91
91
|
@global = global
|
92
|
+
@start = start
|
92
93
|
@label = nil
|
93
94
|
@since = 0
|
94
95
|
@query = nil
|
95
96
|
@repeats = 1
|
96
|
-
@quota_aware =
|
97
|
+
@quota_aware = true
|
98
|
+
@lifetime_aware = true
|
97
99
|
end
|
98
100
|
|
99
101
|
# Makes the iterator aware of GitHub API quota limits.
|
@@ -106,8 +108,15 @@ class Fbe::Iterate
|
|
106
108
|
# @example Enable quota awareness
|
107
109
|
# iterator.quota_aware
|
108
110
|
# iterator.over { |repo, item| ... } # Will stop if quota exhausted
|
109
|
-
def
|
110
|
-
@quota_aware =
|
111
|
+
def quota_unaware
|
112
|
+
@quota_aware = false
|
113
|
+
end
|
114
|
+
|
115
|
+
# Makes the iterator aware of lifetime limits.
|
116
|
+
#
|
117
|
+
# @return [nil] Nothing is returned
|
118
|
+
def lifetime_unaware
|
119
|
+
@lifetime_aware = false
|
111
120
|
end
|
112
121
|
|
113
122
|
# Sets the maximum number of iterations per repository.
|
@@ -188,7 +197,6 @@ class Fbe::Iterate
|
|
188
197
|
# 4. If query returns a value: call the block with (repo_id, query_result)
|
189
198
|
# 5. Store the block's return value as the new "latest" for next iteration
|
190
199
|
#
|
191
|
-
# @param [Float] timeout Maximum seconds to run (default: 120)
|
192
200
|
# @yield [Integer, Object] Repository ID and the result from query execution
|
193
201
|
# @yieldreturn [Integer] The value to store as "latest" for next iteration
|
194
202
|
# @return [nil] Nothing is returned
|
@@ -198,7 +206,7 @@ class Fbe::Iterate
|
|
198
206
|
# fetch_and_process_issue(repo_id, issue_number)
|
199
207
|
# issue_number + 1 # Return next issue number to process
|
200
208
|
# end
|
201
|
-
def over
|
209
|
+
def over
|
202
210
|
raise 'Use "as" first' if @label.nil?
|
203
211
|
raise 'Use "by" first' if @query.nil?
|
204
212
|
seen = {}
|
@@ -211,7 +219,7 @@ class Fbe::Iterate
|
|
211
219
|
loog: @loog, options: @options, global: @global, quota_aware: @quota_aware
|
212
220
|
).map { |n| oct.repo_id_by_name(n) }
|
213
221
|
restarted = []
|
214
|
-
|
222
|
+
started = Time.now
|
215
223
|
before =
|
216
224
|
repos.to_h do |repo|
|
217
225
|
[
|
@@ -228,10 +236,10 @@ class Fbe::Iterate
|
|
228
236
|
starts = before.dup
|
229
237
|
loop do
|
230
238
|
if @quota_aware && oct.off_quota?
|
231
|
-
@loog.info("We are off GitHub quota, time to stop after #{
|
239
|
+
@loog.info("We are off GitHub quota, time to stop after #{started.ago}")
|
232
240
|
break
|
233
241
|
end
|
234
|
-
if Time.now - start >
|
242
|
+
if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
|
235
243
|
@loog.info('We are over time, it is time to stop')
|
236
244
|
break
|
237
245
|
end
|
@@ -240,8 +248,8 @@ class Fbe::Iterate
|
|
240
248
|
@loog.info("We are off GitHub quota, we must skip #{repo}")
|
241
249
|
break
|
242
250
|
end
|
243
|
-
if Time.now - start >
|
244
|
-
@loog.info("We are
|
251
|
+
if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
|
252
|
+
@loog.info("We are working for #{started.ago} already, won't check repository ##{repo}")
|
245
253
|
next
|
246
254
|
end
|
247
255
|
next if restarted.include?(repo)
|
@@ -266,11 +274,11 @@ class Fbe::Iterate
|
|
266
274
|
seen[repo] += 1
|
267
275
|
end
|
268
276
|
unless seen.any? { |r, v| v < @repeats && !restarted.include?(r) }
|
269
|
-
@loog.debug("No more repos to scan (out of #{repos.size}), quitting after #{
|
277
|
+
@loog.debug("No more repos to scan (out of #{repos.size}), quitting after #{started.ago}")
|
270
278
|
break
|
271
279
|
end
|
272
280
|
if restarted.size == repos.size
|
273
|
-
@loog.debug("All #{repos.size} repos restarted, quitting after #{
|
281
|
+
@loog.debug("All #{repos.size} repos restarted, quitting after #{started.ago}")
|
274
282
|
break
|
275
283
|
end
|
276
284
|
end
|
@@ -284,6 +292,6 @@ class Fbe::Iterate
|
|
284
292
|
end
|
285
293
|
Fbe.overwrite(f, @label, before[repo], fb: @fb)
|
286
294
|
end
|
287
|
-
@loog.debug("Finished scanning #{repos.size} repos in #{
|
295
|
+
@loog.debug("Finished scanning #{repos.size} repos in #{started.ago}: #{seen.map { |k, v| "#{k}:#{v}" }.joined}")
|
288
296
|
end
|
289
297
|
end
|
data/lib/fbe.rb
CHANGED