Skip to content

Commit

Permalink
#412: total_reviews_submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 19, 2024
1 parent dc57039 commit ffec01d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
10 changes: 0 additions & 10 deletions judges/quantity-of-deliverables/quantity-of-deliverables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,4 @@
!json[:draft] && json[:published_at] && json[:published_at] > f.since
end
end

# Total number of code reviews in all repositories from since
f.total_reviews_submitted =
Fbe.unmask_repos.sum do |repo|
Fbe.octo.pull_requests(repo, state: 'all').sum do |pr|
Fbe.octo.pull_request_reviews(repo, pr[:number]).count do |review|
review[:submitted_at] && review[:submitted_at] > f.since
end
end
end
end
4 changes: 2 additions & 2 deletions judges/quantity-of-deliverables/total_builds_ran.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
# @param [Factbase::Fact] fact The fact just under processing
# @return [Hash] Map with keys as fact attributes and values as integers
def total_builds_ran(fact)
t =
total =
Fbe.unmask_repos.sum do |repo|
Fbe.octo.repository_workflow_runs(repo, created: ">#{fact.since.utc.iso8601[0..9]}")[:total_count]
end
{ total_builds_ran: t }
{ total_builds_ran: total }
end
44 changes: 44 additions & 0 deletions judges/quantity-of-deliverables/total_reviews_submitted.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'fbe/octo'
require 'fbe/unmask_repos'

# Total number of code reviews in all repositories from since
#
# This function is called from the "quantity-of-deliverables.rb".
#
# @param [Factbase::Fact] fact The fact just under processing
# @return [Hash] Map with keys as fact attributes and values as integers
def total_reviews_submitted(fact)
total =
Fbe.unmask_repos.sum do |repo|
Fbe.octo.pull_requests(repo, state: 'all').sum do |pr|
Fbe.octo.pull_request_reviews(repo, pr[:number]).count do |review|
review[:submitted_at] && review[:submitted_at] > fact.since
end
end
end
{ total_reviews_submitted: total }
end

0 comments on commit ffec01d

Please sign in to comment.