Skip to content

Commit 98cd192

Browse files
committedMar 13, 2025··
#492 factbase up
1 parent 10710ac commit 98cd192

13 files changed

+48
-35
lines changed
 

‎Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
source 'https://rubygems.org'
77

88
gem 'decoor', '>0'
9-
gem 'factbase', '>=0.8.0'
10-
gem 'fbe', '>=0.0.86'
11-
gem 'judges', '>=0.36.2'
9+
gem 'factbase', '>=0.9.1'
10+
gem 'fbe', '>=0.2.1'
11+
gem 'judges', '>=0.36.3'
1212
gem 'minitest', '5.25.4', require: false
1313
gem 'minitest-reporters', '1.7.1', require: false
1414
gem 'others', '>0'

‎Gemfile.lock

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
activesupport (8.0.1)
4+
activesupport (8.0.2)
55
base64
66
benchmark (>= 0.3)
77
bigdecimal
@@ -48,7 +48,7 @@ GEM
4848
tago (> 0)
4949
ethon (0.16.0)
5050
ffi (>= 1.15.0)
51-
factbase (0.8.0)
51+
factbase (0.9.1)
5252
backtrace (>= 0.4.0)
5353
decoor (>= 0.0.1)
5454
json (~> 2.7)
@@ -69,11 +69,11 @@ GEM
6969
net-http (>= 0.5.0)
7070
faraday-retry (2.2.1)
7171
faraday (~> 2.0)
72-
fbe (0.1.0)
72+
fbe (0.2.1)
7373
backtrace (~> 0)
7474
baza.rb (~> 0)
7575
decoor (~> 0)
76-
factbase (>= 0.7.4)
76+
factbase (>= 0.9.1)
7777
faraday (~> 2)
7878
faraday-http-cache (~> 2)
7979
faraday-multipart (~> 1)
@@ -92,7 +92,7 @@ GEM
9292
fiber-storage (1.0.0)
9393
gli (2.22.2)
9494
ostruct
95-
graphql (2.4.11)
95+
graphql (2.4.13)
9696
base64
9797
fiber-storage
9898
logger
@@ -103,13 +103,13 @@ GEM
103103
i18n (1.14.7)
104104
concurrent-ruby (~> 1.0)
105105
iri (0.10.0)
106-
json (2.10.1)
107-
judges (0.36.2)
106+
json (2.10.2)
107+
judges (0.36.3)
108108
backtrace (~> 0)
109109
baza.rb (~> 0)
110110
concurrent-ruby (~> 1.2)
111111
elapsed (~> 0)
112-
factbase (>= 0.7.5)
112+
factbase (>= 0.9.1)
113113
gli (~> 2.21)
114114
iri (~> 0)
115115
loog (~> 0)
@@ -226,9 +226,9 @@ PLATFORMS
226226

227227
DEPENDENCIES
228228
decoor (> 0)
229-
factbase (>= 0.8.0)
230-
fbe (>= 0.0.86)
231-
judges (>= 0.36.2)
229+
factbase (>= 0.9.1)
230+
fbe (>= 0.2.1)
231+
judges (>= 0.36.3)
232232
minitest (= 5.25.4)
233233
minitest-reporters (= 1.7.1)
234234
others (> 0)

‎Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ require 'rubygems'
77
require 'rake'
88
require 'rake/clean'
99

10+
ENV['RACK_RUN'] = 'true'
11+
1012
task default: %i[clean test judges rubocop]
1113

1214
require 'rake/testtask'

‎judges/github-events/github-events.rb

+16-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ def self.fetch_tag(fact, repo)
3333
tag = Fbe.octo.release(
3434
"https://api.github.com/repos/#{repo}/releases/#{fact.release_id}"
3535
).fetch(:tag_name, nil)
36+
$loog.debug("The release ##{fact.release_id} has this tag: #{tag.inspect}")
3637
end
3738
tag
3839
end
3940

4041
def self.fetch_contributors(fact, repo)
41-
last = Fbe.fb.query("(and (eq repository #{fact.repository}) (eq what \"#{fact.what}\"))").each.last
42+
last = Fbe.fb.query("(and (eq repository #{fact.repository}) (eq what \"#{fact.what}\"))").each.to_a.last
4243
tag = fetch_tag(last, repo)
4344
contributors = Set.new
4445
if tag
@@ -51,11 +52,12 @@ def self.fetch_contributors(fact, repo)
5152
contributors << contributor[:id]
5253
end
5354
end
55+
$loog.debug("The repository ##{fact.repository} has #{contributors.count} contributors")
5456
contributors.to_a
5557
end
5658

5759
def self.fetch_release_info(fact, repo)
58-
last = Fbe.fb.query("(and (eq repository #{fact.repository}) (eq what \"#{fact.what}\"))").each.last
60+
last = Fbe.fb.query("(and (eq repository #{fact.repository}) (eq what \"#{fact.what}\"))").each.to_a.last
5961
tag = fetch_tag(last, repo)
6062
tag ||= find_first_commit(repo)[:sha]
6163
info = {}
@@ -64,6 +66,7 @@ def self.fetch_release_info(fact, repo)
6466
info[:hoc] = json[:files].sum { |f| f[:changes] }
6567
info[:last_commit] = json[:commits].first[:sha]
6668
end
69+
$loog.debug("The repository ##{fact.repository} has this: #{info.inspect}")
6770
info
6871
end
6972

@@ -74,6 +77,7 @@ def self.find_first_commit(repo)
7477
commits = Fbe.octo.commits(repo, sha: last[:sha])
7578
last = commits.last
7679
end
80+
$loog.debug("The repo ##{repo} has this last commit: #{last}")
7781
last
7882
end
7983

@@ -172,6 +176,7 @@ def self.fill_up_event(fact, json)
172176
"A new Git push ##{json[:payload][:push_id]} has arrived to #{rname}, " \
173177
"made by #{Fbe.who(fact)} (default branch is '#{fact.default_branch}'), " \
174178
'not associated with any pull request.'
179+
$loog.debug("New PushEvent ##{json[:payload][:push_id]} recorded")
175180

176181
when 'PullRequestEvent'
177182
pl = json[:payload][:pull_request]
@@ -181,6 +186,7 @@ def self.fill_up_event(fact, json)
181186
fact.what = 'pull-was-opened'
182187
fact.branch = pl[:head][:ref]
183188
fact.details = "The pull request #{Fbe.issue(fact)} has been opened by #{Fbe.who(fact)}."
189+
$loog.debug("New PR #{Fbe.issue(fact)} opened by #{Fbe.who(fact)}")
184190
when 'closed'
185191
fact.what = "pull-was-#{pl[:merged_at].nil? ? 'closed' : 'merged'}"
186192
fact.hoc = pl[:additions] + pl[:deletions]
@@ -191,6 +197,7 @@ def self.fill_up_event(fact, json)
191197
"The pull request #{Fbe.issue(fact)} " \
192198
"has been #{json[:payload][:action]} by #{Fbe.who(fact)}, " \
193199
"with #{fact.hoc} HoC and #{fact.comments} comments."
200+
$loog.debug("PR #{Fbe.issue(fact)} closed by #{Fbe.who(fact)}")
194201
else
195202
skip_event(json)
196203
end
@@ -204,7 +211,7 @@ def self.fill_up_event(fact, json)
204211
'(eq what "pull-was-reviewed") ' \
205212
"(eq who #{fact.who}) " \
206213
"(eq issue #{json[:payload][:pull_request][:number]}))"
207-
).each.last
214+
).each.to_a.last
208215
skip_event(json)
209216
end
210217
skip_event(json) unless json[:payload][:review][:state] == 'approved'
@@ -220,6 +227,7 @@ def self.fill_up_event(fact, json)
220227
"The pull request #{Fbe.issue(fact)} " \
221228
"has been reviewed by #{Fbe.who(fact)} " \
222229
"with #{fact.hoc} HoC and #{fact.comments} comments."
230+
$loog.debug("PR #{Fbe.issue(fact)} was reviewed by #{Fbe.who(fact)}")
223231
else
224232
skip_event(json)
225233
end
@@ -230,9 +238,11 @@ def self.fill_up_event(fact, json)
230238
when 'closed'
231239
fact.what = 'issue-was-closed'
232240
fact.details = "The issue #{Fbe.issue(fact)} has been closed by #{Fbe.who(fact)}."
241+
$loog.debug("Issue #{Fbe.issue(fact)} closed by #{Fbe.who(fact)}")
233242
when 'opened'
234243
fact.what = 'issue-was-opened'
235244
fact.details = "The issue #{Fbe.issue(fact)} has been opened by #{Fbe.who(fact)}."
245+
$loog.debug("Issue #{Fbe.issue(fact)} opened by #{Fbe.who(fact)}")
236246
else
237247
skip_event(json)
238248
end
@@ -249,6 +259,7 @@ def self.fill_up_event(fact, json)
249259
fact.details =
250260
"A new comment ##{json[:payload][:comment][:id]} has been posted " \
251261
"to #{Fbe.issue(fact)} by #{Fbe.who(fact)}."
262+
$loog.debug("Issue comment posted to #{Fbe.issue(fact)} by #{Fbe.who(fact)}")
252263
end
253264
skip_event(json)
254265

@@ -264,6 +275,7 @@ def self.fill_up_event(fact, json)
264275
fact.details =
265276
"A new release '#{json[:payload][:release][:name]}' has been published " \
266277
"in #{rname} by #{Fbe.who(fact)}."
278+
$loog.debug("Release published by #{Fbe.who(fact)}")
267279
else
268280
skip_event(json)
269281
end
@@ -276,6 +288,7 @@ def self.fill_up_event(fact, json)
276288
fact.details =
277289
"A new tag '#{fact.tag}' has been created " \
278290
"in #{rname} by #{Fbe.who(fact)}."
291+
$loog.debug("Tag #{fact.tag.inspect} created by #{Fbe.who(fact)}")
279292
else
280293
skip_event(json)
281294
end

‎judges/who-has-name/who-has-name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def name_of(who)
3838
(eq what 'who-has-name')
3939
(eq where 'github')
4040
(exists who)
41-
(lt when #{(Time.now - (5 * 24 * 60 * 60)).utc.iso8601}))"
41+
(lt when (minus (to_time (env 'TODAY' '#{Time.now.utc.iso8601}')) '5 days')))"
4242
).each.to_a.each do |f|
4343
Fbe.overwrite(f, 'name', name_of(f.who))
4444
end

‎test/judges/test-dimensions-of-terrain.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
# SPDX-License-Identifier: MIT
55

66
require 'factbase'
7-
require 'fbe/octo'
87
require 'fbe/github_graph'
9-
require 'loog'
8+
require 'fbe/octo'
109
require 'json'
11-
require 'minitest/autorun'
12-
require 'webmock/minitest'
1310
require 'judges/options'
11+
require 'loog'
12+
require 'webmock/minitest'
1413
require_relative '../test__helper'
1514

1615
# Test.

‎test/judges/test-find-all-issues.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# SPDX-License-Identifier: MIT
55

66
require 'factbase'
7-
require 'loog'
87
require 'json'
9-
require 'minitest/autorun'
10-
require 'webmock/minitest'
118
require 'judges/options'
9+
require 'loog'
10+
require 'webmock/minitest'
11+
require_relative '../test__helper'
1212

1313
# Test.
1414
class TestFindAllIssues < Minitest::Test

‎test/judges/test-github-events.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
require 'factbase'
77
require 'loog'
88
require 'json'
9-
require 'minitest/autorun'
109
require 'webmock/minitest'
1110
require 'judges/options'
1211
require 'fbe'
1312
require 'fbe/github_graph'
13+
require_relative '../test__helper'
1414

1515
# Test.
1616
# Author:: Yegor Bugayenko (yegor256@gmail.com)

‎test/judges/test-label-was-attached.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# SPDX-License-Identifier: MIT
55

66
require 'factbase'
7-
require 'loog'
87
require 'json'
9-
require 'minitest/autorun'
10-
require 'webmock/minitest'
118
require 'judges/options'
9+
require 'loog'
10+
require 'webmock/minitest'
11+
require_relative '../test__helper'
1212

1313
# Test.
1414
# Author:: Yegor Bugayenko (yegor256@gmail.com)

‎test/judges/test-quality-of-service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
require 'factbase'
77
require 'loog'
88
require 'json'
9-
require 'minitest/autorun'
109
require 'webmock/minitest'
1110
require 'judges/options'
11+
require_relative '../test__helper'
1212

1313
# Test.
1414
# Author:: Yegor Bugayenko (yegor256@gmail.com)

‎test/judges/test-quantity-of-deliverables.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# SPDX-License-Identifier: MIT
55

66
require 'factbase'
7-
require 'loog'
87
require 'json'
9-
require 'minitest/autorun'
10-
require 'webmock/minitest'
118
require 'judges/options'
9+
require 'loog'
10+
require 'webmock/minitest'
1211
require_relative '../test__helper'
1312

1413
# Test.

‎test/judges/test-who-has-name.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# SPDX-License-Identifier: MIT
55

66
require 'factbase'
7-
require 'minitest/autorun'
87
require 'webmock/minitest'
8+
require_relative '../test__helper'
99

1010
# Test.
1111
# Author:: Yegor Bugayenko (yegor256@gmail.com)

‎test/test__helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def load_it(judge, fb, options = Judges::Options.new({ 'repositories' => 'foo/fo
2323
$local = {}
2424
$judge = judge
2525
$options = options
26-
$loog = Loog::NULL
26+
$loog = ENV['RACK_RUN'] ? Loog::NULL : Loog::VERBOSE
2727
$start = Time.now
2828
load(File.join(__dir__, "../judges/#{judge}/#{judge}.rb"))
2929
end

1 commit comments

Comments
 (1)

0crat commented on Mar 20, 2025

@0crat

@yegor256 It is not a good idea to push directly to the default branch master. You've earned -16 points. Next time, create a new branch, push your changes over there, then make a pull request and merge it. Even if you are flying solo, contributing via pull requests is a good practice.

Please sign in to comment.