Skip to content

Commit

Permalink
largest
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 4, 2024
1 parent c889743 commit 065e3f2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zerocracy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
token: ${{ secrets.ZEROCRACY_TOKEN }}
verbose: true
options: |
max_events=2
max_events=200
token=${{ secrets.GITHUB_TOKEN }}
repositories=yegor256/judges,yegor256/factbase,zerocracy/judges-action,zerocracy/pages-action
factbase: zerocracy.fb
Expand Down
25 changes: 15 additions & 10 deletions judges/github-events/github-events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,23 @@ def put_new_event(fbt, json)
'this fact must be interpreted later by other judges.'
end

# Taking the largest ID of GitHub event that was seen so far (or NIL)
def largest(repo)
largest = fb.query(
"(eq event_id
(agg (eq repository #{octo.repo_id_by_name(repo)})
(max event_id)))"
).each.to_a[0]
unless largest.nil?
largest = largest.event_id
$loog.debug("The largest ID we've seen so far is #{largest} (everything below this number will be ignored)")
end
largest
end

def one_repo(repo, seen)
catch :stop do
# Taking the largest ID of GitHub event that was seen so far:
largest = fb.query(
"(eq event_id
(agg (eq repository #{octo.repo_id_by_name(repo)})
(max event_id)))"
).each.to_a[0]
unless largest.nil?
largest = largest.event_id
$loog.debug("The largest ID we've seen so far is #{largest} (everything below this number will be ignored)")
end
largest = largest(repo)
octo.repository_events(repo).each do |json|
unless fb.query("(eq event_id #{json[:id]})").each.to_a.empty?
$loog.debug("The event ##{json[:id]} (#{json[:type]}) has already been seen, skipping")
Expand Down
11 changes: 6 additions & 5 deletions judges/label-was-attached/label-was-attached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,19 @@ def max(repo)
next unless te[:event] == 'labeled'
badge = te[:label][:name]
next unless %w[bug enhancement question].include?(badge)
if_absent(fb) do |n|
nn = if_absent(fb) do |n|
n.repository = f.repository
n.issue = f.issue
n.label = te[:label][:name]
n.who = te[:actor][:id]
n.when = te[:created_at]
n.what = $judge
n.details =
"The '##{n.label}' label was attached by @#{te[:actor][:login]} " \
"to the issue #{octo.repo_name_by_id(n.repository)}##{n.issue} " \
"at #{n.when.utc.iso8601}; this may trigger future judges."
end
next if nn.nil?
nn.details =
"The '##{nn.label}' label was attached by @#{te[:actor][:login]} " \
"to the issue #{octo.repo_name_by_id(nn.repository)}##{nn.issue} " \
"at #{nn.when.utc.iso8601}; this may trigger future judges."
end
f.seen = $judge
end
Expand Down

0 comments on commit 065e3f2

Please sign in to comment.