diff --git a/Gemfile.lock b/Gemfile.lock index a55ee8a0..fc4f7451 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/judges/dimensions-of-terrain/dimensions-of-terrain.rb b/judges/dimensions-of-terrain/dimensions-of-terrain.rb index a38bd960..e3696a32 100644 --- a/judges/dimensions-of-terrain/dimensions-of-terrain.rb +++ b/judges/dimensions-of-terrain/dimensions-of-terrain.rb @@ -24,6 +24,7 @@ require 'fbe/fb' require 'fbe/octo' +require 'fbe/github_graph' require 'fbe/unmask_repos' unless Fbe.fb.query( @@ -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 diff --git a/judges/dimensions-of-terrain/measure-all.yml b/judges/dimensions-of-terrain/measure-all.yml index 608afc73..1f154dd1 100644 --- a/judges/dimensions-of-terrain/measure-all.yml +++ b/judges/dimensions-of-terrain/measure-all.yml @@ -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] diff --git a/test/judges/test-dimensions-of-terrain.rb b/test/judges/test-dimensions-of-terrain.rb new file mode 100644 index 00000000..cf2efdc3 --- /dev/null +++ b/test/judges/test-dimensions-of-terrain.rb @@ -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