Skip to content

Commit

Permalink
#200: calculate total number of issues and pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegorov committed Sep 24, 2024
1 parent 0a37cb1 commit 291a660
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
12 changes: 12 additions & 0 deletions judges/dimensions-of-terrain/dimensions-of-terrain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

require 'fbe/fb'
require 'fbe/octo'
require 'fbe/github_graph'
require 'fbe/unmask_repos'

unless Fbe.fb.query(
Expand Down Expand Up @@ -66,3 +67,14 @@
end
f.total_stars = stars
f.total_forks = forks

# Total number of issues and pull requests for all repos
issues = 0
pulls = 0
Fbe.unmask_repos.each do |repo|
json = Fbe.github_graph.total_issues_and_pulls(*repo.split('/'))
issues += json['issues']
pulls += json['pulls']
end
f.total_issues = issues
f.total_pulls = pulls
2 changes: 2 additions & 0 deletions judges/dimensions-of-terrain/measure-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ expected:
- /fb/f[total_releases]
- /fb/f[total_stars]
- /fb/f[total_forks]
- /fb/f[total_issues]
- /fb/f[total_pulls]
42 changes: 42 additions & 0 deletions test/judges/test-dimensions-of-terrain.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 'factbase'
require 'loog'
require 'json'
require 'minitest/autorun'
require 'webmock/minitest'
require 'judges/options'

# Test.
class TestDimensionsOfTerrain < Minitest::Test
def test_total_issues_and_pull_requests
WebMock.disable_net_connect!
fb = Factbase.new
load_it('dimensions-of-terrain', fb, Judges::Options.new({ 'repositories' => 'foo/foo', 'testing' => true }))
f = fb.query("(eq what 'dimensions-of-terrain')").each.to_a.first
assert_equal(23, f.total_issues)
assert_equal(19, f.total_pulls)
end
end

0 comments on commit 291a660

Please sign in to comment.