fbe 0.34.4 → 0.36.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 +8 -8
- data/lib/fbe/conclude.rb +9 -10
- data/lib/fbe/iterate.rb +20 -4
- data/lib/fbe/just_one.rb +1 -1
- data/lib/fbe/octo.rb +38 -3
- data/lib/fbe/pmp.rb +1 -1
- data/lib/fbe/regularly.rb +10 -4
- data/lib/fbe/repeatedly.rb +5 -5
- 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: 1abd50441a009aeaeb0356a59d62ace51e0817be9adc75d7b5a20bc2b7f61c7b
|
4
|
+
data.tar.gz: 4d69963715216537a4aad166d73a79f9b90dea223fb37749f092100a2d875f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a644ef1b41c7e0b9bd46873bc5e939fa4b4d38f4492a580a869a120f7eff28225f3fd0cf396d41c901135f193f78aec90e2f6cb079833cd3f85466da2fd0c7dd
|
7
|
+
data.tar.gz: e12946cc6d117d3dee3243775f3bdc9cec2b6b2314d1c15217f986046e83ab536e6a954f31fb1f466cbe6e9f7918d4fec80889ef0146430620d9559f3fcfccf4
|
data/Gemfile.lock
CHANGED
@@ -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.16.
|
79
|
+
factbase (0.16.5)
|
80
80
|
backtrace (~> 0.4)
|
81
81
|
decoor (~> 0.1)
|
82
82
|
ellipsized (~> 0.3)
|
@@ -107,7 +107,7 @@ GEM
|
|
107
107
|
filesize (0.2.0)
|
108
108
|
gli (2.22.2)
|
109
109
|
ostruct
|
110
|
-
graphql (2.5.
|
110
|
+
graphql (2.5.12)
|
111
111
|
base64
|
112
112
|
fiber-storage
|
113
113
|
logger
|
@@ -157,13 +157,13 @@ GEM
|
|
157
157
|
multipart-post (2.4.1)
|
158
158
|
net-http (0.6.0)
|
159
159
|
uri
|
160
|
-
nokogiri (1.18.
|
160
|
+
nokogiri (1.18.10-arm64-darwin)
|
161
161
|
racc (~> 1.4)
|
162
|
-
nokogiri (1.18.
|
162
|
+
nokogiri (1.18.10-x64-mingw-ucrt)
|
163
163
|
racc (~> 1.4)
|
164
|
-
nokogiri (1.18.
|
164
|
+
nokogiri (1.18.10-x86_64-darwin)
|
165
165
|
racc (~> 1.4)
|
166
|
-
nokogiri (1.18.
|
166
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
167
167
|
racc (~> 1.4)
|
168
168
|
obk (0.3.2)
|
169
169
|
octokit (10.0.0)
|
@@ -176,7 +176,7 @@ GEM
|
|
176
176
|
parser (3.3.9.0)
|
177
177
|
ast (~> 2.4.1)
|
178
178
|
racc
|
179
|
-
prism (1.
|
179
|
+
prism (1.5.1)
|
180
180
|
public_suffix (6.0.2)
|
181
181
|
qbash (0.4.5)
|
182
182
|
backtrace (> 0)
|
@@ -186,7 +186,7 @@ GEM
|
|
186
186
|
racc (1.8.1)
|
187
187
|
rainbow (3.1.1)
|
188
188
|
rake (13.3.0)
|
189
|
-
regexp_parser (2.11.
|
189
|
+
regexp_parser (2.11.3)
|
190
190
|
retries (0.0.5)
|
191
191
|
rexml (3.4.4)
|
192
192
|
rubocop (1.80.2)
|
data/lib/fbe/conclude.rb
CHANGED
@@ -71,8 +71,8 @@ class Fbe::Conclude
|
|
71
71
|
@query = nil
|
72
72
|
@follows = []
|
73
73
|
@lifetime_aware = true
|
74
|
+
@timeout_aware = true
|
74
75
|
@quota_aware = true
|
75
|
-
@timeout = 60
|
76
76
|
end
|
77
77
|
|
78
78
|
# Make this block not aware of GitHub API quota.
|
@@ -94,15 +94,13 @@ class Fbe::Conclude
|
|
94
94
|
@lifetime_aware = false
|
95
95
|
end
|
96
96
|
|
97
|
-
# Make
|
97
|
+
# Make this block NOT aware of timeout limitations.
|
98
98
|
#
|
99
|
-
# When the
|
100
|
-
# This helps prevent interruptions in long-running operations.
|
99
|
+
# When the timeout is over, the loop will NOT gracefully stop.
|
101
100
|
#
|
102
|
-
# @param [Float] sec Seconds
|
103
101
|
# @return [nil] Nothing is returned
|
104
|
-
def
|
105
|
-
@
|
102
|
+
def timeout_unaware
|
103
|
+
@timeout_aware = false
|
106
104
|
end
|
107
105
|
|
108
106
|
# Set the query that should find the facts in the factbase.
|
@@ -194,17 +192,18 @@ class Fbe::Conclude
|
|
194
192
|
def roll(&)
|
195
193
|
passed = 0
|
196
194
|
oct = Fbe.octo(loog: @loog, options: @options, global: @global)
|
195
|
+
started = Time.now
|
197
196
|
@fb.query(@query).each do |a|
|
198
197
|
if @quota_aware && oct.off_quota?
|
199
198
|
@loog.info('We ran out of GitHub quota, must stop here')
|
200
199
|
break
|
201
200
|
end
|
202
201
|
if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
|
203
|
-
@loog.debug(
|
202
|
+
@loog.debug("We ran out of lifetime (#{@start.ago} already), must stop here")
|
204
203
|
break
|
205
204
|
end
|
206
|
-
if Time.now > @
|
207
|
-
@loog.debug("We've spent more than #{
|
205
|
+
if @timeout_aware && @options.timeout && Time.now - started > @options.timeout - 5
|
206
|
+
@loog.debug("We've spent more than #{started.ago}, must stop here")
|
208
207
|
break
|
209
208
|
end
|
210
209
|
@fb.txn do |fbt|
|
data/lib/fbe/iterate.rb
CHANGED
@@ -32,7 +32,7 @@ require_relative 'unmask_repos'
|
|
32
32
|
# by '(and (eq what "issue") (gt created_at $before))'
|
33
33
|
# repeats 5
|
34
34
|
# quota_aware
|
35
|
-
# over
|
35
|
+
# over do |repository_id, issue_id|
|
36
36
|
# process_issue(repository_id, issue_id)
|
37
37
|
# issue_id + 1
|
38
38
|
# end
|
@@ -96,6 +96,7 @@ class Fbe::Iterate
|
|
96
96
|
@repeats = 1
|
97
97
|
@quota_aware = true
|
98
98
|
@lifetime_aware = true
|
99
|
+
@timeout_aware = true
|
99
100
|
end
|
100
101
|
|
101
102
|
# Makes the iterator aware of GitHub API quota limits.
|
@@ -119,6 +120,13 @@ class Fbe::Iterate
|
|
119
120
|
@lifetime_aware = false
|
120
121
|
end
|
121
122
|
|
123
|
+
# Makes the iterator aware of timeout limits.
|
124
|
+
#
|
125
|
+
# @return [nil] Nothing is returned
|
126
|
+
def timeout_unaware
|
127
|
+
@timeout_aware = false
|
128
|
+
end
|
129
|
+
|
122
130
|
# Sets the maximum number of iterations per repository.
|
123
131
|
#
|
124
132
|
# Controls how many times the query will be executed for each repository
|
@@ -202,7 +210,7 @@ class Fbe::Iterate
|
|
202
210
|
# @return [nil] Nothing is returned
|
203
211
|
# @raise [RuntimeError] If block doesn't return an Integer
|
204
212
|
# @example Process issues incrementally
|
205
|
-
# iterator.over
|
213
|
+
# iterator.over do |repo_id, issue_number|
|
206
214
|
# fetch_and_process_issue(repo_id, issue_number)
|
207
215
|
# issue_number + 1 # Return next issue number to process
|
208
216
|
# end
|
@@ -240,7 +248,11 @@ class Fbe::Iterate
|
|
240
248
|
break
|
241
249
|
end
|
242
250
|
if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
|
243
|
-
@loog.
|
251
|
+
@loog.debug("We ran out of lifetime (#{@start.ago} already), must stop here")
|
252
|
+
break
|
253
|
+
end
|
254
|
+
if @timeout_aware && @options.timeout && Time.now - started > @options.timeout - 5
|
255
|
+
@loog.debug("We've spent more than #{started.ago}, must stop here")
|
244
256
|
break
|
245
257
|
end
|
246
258
|
repos.each do |repo|
|
@@ -249,9 +261,13 @@ class Fbe::Iterate
|
|
249
261
|
break
|
250
262
|
end
|
251
263
|
if @lifetime_aware && @options.lifetime && Time.now - @start > @options.lifetime - 10
|
252
|
-
@loog.info("We are working for #{
|
264
|
+
@loog.info("We are working for #{@start.ago} already, won't check repository ##{repo}")
|
253
265
|
next
|
254
266
|
end
|
267
|
+
if @timeout_aware && @options.timeout && Time.now - started > @options.timeout - 5
|
268
|
+
@loog.debug("We've spent more than #{started.ago}, won't check repository ##{repo}")
|
269
|
+
break
|
270
|
+
end
|
255
271
|
next if restarted.include?(repo)
|
256
272
|
seen[repo] = 0 if seen[repo].nil?
|
257
273
|
if seen[repo] >= @repeats
|
data/lib/fbe/just_one.rb
CHANGED
data/lib/fbe/octo.rb
CHANGED
@@ -198,6 +198,24 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
|
|
198
198
|
@loog.debug("GitHub repository ##{id} has a name: #{name}")
|
199
199
|
name
|
200
200
|
end
|
201
|
+
|
202
|
+
# Disable auto pagination for octokit client called in block
|
203
|
+
#
|
204
|
+
# @yield [octo] Give octokit client with disabled auto pagination
|
205
|
+
# @yieldparam [Octokit::Client, Fbe::FakeOctokit] Octokit client
|
206
|
+
# @return [Object] Last value in block
|
207
|
+
# @example
|
208
|
+
# issue =
|
209
|
+
# Fbe.octo.with_disable_auto_paginate do |octo|
|
210
|
+
# octo.list_issue('zerocracy/fbe', per_page: 1).first
|
211
|
+
# end
|
212
|
+
def with_disable_auto_paginate
|
213
|
+
ap = @origin.auto_paginate
|
214
|
+
@origin.auto_paginate = false
|
215
|
+
yield self if block_given?
|
216
|
+
ensure
|
217
|
+
@origin.auto_paginate = ap
|
218
|
+
end
|
201
219
|
end
|
202
220
|
o =
|
203
221
|
intercepted(o) do |e, m, _args, _r|
|
@@ -251,6 +269,10 @@ class Fbe::FakeOctokit
|
|
251
269
|
name.chars.sum(&:ord)
|
252
270
|
end
|
253
271
|
|
272
|
+
def auto_paginate=(_); end
|
273
|
+
|
274
|
+
def auto_paginate; end
|
275
|
+
|
254
276
|
# Returns a mock rate limit object.
|
255
277
|
#
|
256
278
|
# @return [Object] An object with a remaining method that returns 100
|
@@ -588,6 +610,7 @@ class Fbe::FakeOctokit
|
|
588
610
|
raise Octokit::NotFound if [404_123, 404_124].include?(name)
|
589
611
|
full_name = name.is_a?(Integer) ? 'yegor256/test' : name
|
590
612
|
full_name = 'zerocracy/baza' if name == 1439
|
613
|
+
full_name = 'foo/bazz' if name == 810
|
591
614
|
{
|
592
615
|
id: name_to_number(name),
|
593
616
|
full_name:,
|
@@ -651,7 +674,9 @@ class Fbe::FakeOctokit
|
|
651
674
|
[
|
652
675
|
issue(repo, 42),
|
653
676
|
issue(repo, 43)
|
654
|
-
]
|
677
|
+
].tap do |list|
|
678
|
+
list.prepend(issue(repo, 144)) if repo == 'foo/bazz'
|
679
|
+
end
|
655
680
|
end
|
656
681
|
|
657
682
|
# Gets a single issue.
|
@@ -663,7 +688,8 @@ class Fbe::FakeOctokit
|
|
663
688
|
# client.issue('octocat/Hello-World', 42)
|
664
689
|
# # => {:id=>42, :number=>42, :created_at=>...}
|
665
690
|
def issue(repo, number)
|
666
|
-
|
691
|
+
case number
|
692
|
+
when 142
|
667
693
|
{
|
668
694
|
id: 655,
|
669
695
|
number:,
|
@@ -675,7 +701,7 @@ class Fbe::FakeOctokit
|
|
675
701
|
closed_at: Time.parse('2025-06-02 15:00:00 UTC'),
|
676
702
|
closed_by: { id: 526_301, login: 'yegor256' }
|
677
703
|
}
|
678
|
-
|
704
|
+
when 143
|
679
705
|
{
|
680
706
|
id: 656,
|
681
707
|
number:,
|
@@ -688,6 +714,15 @@ class Fbe::FakeOctokit
|
|
688
714
|
closed_at: Time.parse('2025-06-01 18:20:00 UTC'),
|
689
715
|
closed_by: { id: 526_301, login: 'yegor256' }
|
690
716
|
}
|
717
|
+
when 144
|
718
|
+
{
|
719
|
+
id: 657,
|
720
|
+
number:,
|
721
|
+
repo: { full_name: repo },
|
722
|
+
user: { login: 'yegor256', id: 526_301, type: 'User' },
|
723
|
+
pull_request: { merged_at: nil },
|
724
|
+
created_at: Time.parse('2025-05-29 17:00:55 UTC')
|
725
|
+
}
|
691
726
|
else
|
692
727
|
{
|
693
728
|
id: 42,
|
data/lib/fbe/pmp.rb
CHANGED
@@ -48,7 +48,7 @@ def Fbe.pmp(fb: Fbe.fb, global: $global, options: $options, loog: $loog)
|
|
48
48
|
end
|
49
49
|
others do |*args2|
|
50
50
|
param = args2.first
|
51
|
-
f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.
|
51
|
+
f = Fbe.fb(global:, fb:, options:, loog:).query("(and (eq what 'pmp') (eq area '#{area}'))").each.first
|
52
52
|
raise "Unknown area #{area.inspect}" if f.nil?
|
53
53
|
r = f[param]
|
54
54
|
raise "Unknown property #{param.inspect} in the #{area.inspect} area" if r.nil?
|
data/lib/fbe/regularly.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
4
|
# SPDX-License-Identifier: MIT
|
5
5
|
|
6
|
+
require 'tago'
|
6
7
|
require_relative '../fbe'
|
7
8
|
require_relative 'fb'
|
8
9
|
|
@@ -34,16 +35,21 @@ def Fbe.regularly(area, p_every_days, p_since_days = nil, fb: Fbe.fb, judge: $ju
|
|
34
35
|
raise 'The fb is nil' if fb.nil?
|
35
36
|
raise 'The $judge is not set' if judge.nil?
|
36
37
|
raise 'The $loog is not set' if loog.nil?
|
37
|
-
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.
|
38
|
+
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_days}))").each.first
|
38
39
|
interval = pmp.nil? ? 7 : pmp[p_every_days].first
|
39
|
-
|
40
|
+
recent = fb.query(
|
40
41
|
"(and
|
41
42
|
(eq what '#{judge}')
|
42
43
|
(gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{interval} days')))"
|
43
|
-
).each.
|
44
|
-
|
44
|
+
).each.first
|
45
|
+
if recent
|
46
|
+
loog.info(
|
47
|
+
"#{$judge} statistics were collected #{recent.when.ago} ago, " \
|
48
|
+
"skipping now (we run it every #{interval} days)"
|
49
|
+
)
|
45
50
|
return
|
46
51
|
end
|
52
|
+
loog.info("#{$judge} statistics weren't collected for the last #{interval} days")
|
47
53
|
fb.txn do |fbt|
|
48
54
|
f = fbt.insert
|
49
55
|
f.what = judge
|
data/lib/fbe/repeatedly.rb
CHANGED
@@ -37,23 +37,23 @@ def Fbe.repeatedly(area, p_every_hours, fb: Fbe.fb, judge: $judge, loog: $loog,
|
|
37
37
|
raise 'The fb is nil' if fb.nil?
|
38
38
|
raise 'The $judge is not set' if judge.nil?
|
39
39
|
raise 'The $loog is not set' if loog.nil?
|
40
|
-
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.
|
40
|
+
pmp = fb.query("(and (eq what 'pmp') (eq area '#{area}') (exists #{p_every_hours}))").each.first
|
41
41
|
hours = pmp.nil? ? 24 : pmp[p_every_hours].first
|
42
42
|
recent = fb.query(
|
43
43
|
"(and
|
44
44
|
(eq what '#{judge}')
|
45
45
|
(gt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '#{hours} hours')))"
|
46
|
-
).each.
|
46
|
+
).each.first
|
47
47
|
if recent
|
48
|
-
loog.info("#{$judge}
|
48
|
+
loog.info("#{$judge} was executed #{recent.when.ago} ago, skipping now (we run it every #{hours} hours)")
|
49
49
|
return
|
50
50
|
end
|
51
|
-
f = fb.query("(and (eq what '#{judge}'))").each.
|
51
|
+
f = fb.query("(and (eq what '#{judge}'))").each.first
|
52
52
|
if f.nil?
|
53
53
|
f = fb.insert
|
54
54
|
f.what = judge
|
55
55
|
end
|
56
56
|
Fbe.overwrite(f, 'when', Time.now)
|
57
|
-
yield fb.query("(and (eq what '#{judge}'))").each.
|
57
|
+
yield fb.query("(and (eq what '#{judge}'))").each.first
|
58
58
|
nil
|
59
59
|
end
|
data/lib/fbe.rb
CHANGED