Skip to content

Commit

Permalink
#412: total_commits
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 18, 2024
1 parent bc849c9 commit 43ff07d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
9 changes: 0 additions & 9 deletions judges/dimensions-of-terrain/dimensions-of-terrain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@
send(n).each { |k, v| f.send("#{k}=", v) }
end

# Total number of commits for all repos
commits = 0
Fbe.unmask_repos.each do |repo|
repo_info = Fbe.octo.repository(repo)
next if repo_info[:size].zero?
commits += Fbe.github_graph.total_commits(*repo.split('/'), repo_info[:default_branch])
end
f.total_commits = commits

# Total number of files for all repos
files = 0
Fbe.unmask_repos.each do |repo|
Expand Down
42 changes: 42 additions & 0 deletions judges/dimensions-of-terrain/total_commits.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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/github_graph'
require 'fbe/unmask_repos'

# Total number of commits for all repos.
#
# This function is called from the "dimensions-of-terrain.rb".
#
# @return Hash Map with keys as fact attributes and values as integers
def total_commits
commits = 0
Fbe.unmask_repos.each do |repo|
repo_info = Fbe.octo.repository(repo)
next if repo_info[:size].zero?
commits += Fbe.github_graph.total_commits(*repo.split('/'), repo_info[:default_branch])
end
{ total_commits: commits }
end

0 comments on commit 43ff07d

Please sign in to comment.