fbe 0.34.4 → 0.35.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/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 +9 -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: 3bddbb890f6001c0df689c40caf9803218154009f27a5510be94599b874d218b
|
4
|
+
data.tar.gz: 2f202ab71bd13a341d545889be0e54daa2a4cc512af81607d12c5e26267eb147
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e22ef6d4ca2d1235418d6b6bcea3a317a962b1dc0b5ac4841becd708df6cd41f838178d08ebd74bb08e25a8cf7f597ca3a9378d4a71cc945f26fe8a8da05a4a0
|
7
|
+
data.tar.gz: 2a771ac3b0ecd1eb64aae745518cac12adb5f5cb24f548829c74b4961856f51d2fa01e5a2fb4c841ba706d664b58740793da621b22a9f7408bc0da769ab843a2
|
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,14 +35,18 @@ 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.debug(
|
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
|
47
52
|
fb.txn do |fbt|
|
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