Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#200: calculate total number of issues and pull requests #348

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ GEM
others (> 0)
tago (> 0)
yaml (~> 0.3)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.1.1)
faraday-net_http (3.3.0)
net-http
faraday-retry (2.2.1)
faraday (~> 2.0)
Expand Down
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
Loading