diff --git a/lib/github/buckets.rb b/lib/github/buckets.rb index 30f3f6e..daa20c2 100644 --- a/lib/github/buckets.rb +++ b/lib/github/buckets.rb @@ -51,7 +51,7 @@ def all_external def all_external_percent return 0 unless all.any? - ((all_external.size.to_f / all_humans.size) * 100).to_i + ((all_external.size.to_f / all_humans.size) * 100).round(1) end def percent diff --git a/lib/github/maintainers.rb b/lib/github/maintainers.rb index 2fc18ce..cda6a43 100644 --- a/lib/github/maintainers.rb +++ b/lib/github/maintainers.rb @@ -21,13 +21,13 @@ def buckets def all_external ALL_EXTERNAL.map do |bucket| buckets[bucket] - end.flatten.compact.uniq + end.flatten.compact end def all_external_unique_percent return 0 unless unique_count - ((all_external_unique_count.to_f / unique_count) * 100).to_i + ((all_external_unique_count.to_f / unique_count) * 100).round(1) end def unique_count diff --git a/lib/github/repos.rb b/lib/github/repos.rb index fd8c027..9eb845d 100644 --- a/lib/github/repos.rb +++ b/lib/github/repos.rb @@ -19,11 +19,11 @@ def unarchived def maintainers(dt = nil) @maintainers ||= begin - all = Set.new + all = [] each do |repo| maintainers = repo.maintainers(dt) maintainers&.each do |user| - all.add(user) + all << user end end GitHub::Maintainers.new(all.to_a) @@ -66,7 +66,7 @@ def all_external_maintained_size def all_external_maintainers_percent return 0 unless any? - (all_external_maintained_size.to_f * 100 / size).to_i + (all_external_maintained_size.to_f * 100 / size).round(1) end end end diff --git a/spec/project/commands/pr_spec.rb b/spec/project/commands/pr_spec.rb index cf90b0e..7ffd639 100644 --- a/spec/project/commands/pr_spec.rb +++ b/spec/project/commands/pr_spec.rb @@ -7,22 +7,22 @@ context 'stats' do it 'returns contributors' do output = `"#{project}" --no-cache --vcr-cassette-name=search/RedHatOfficial/prs_2022-01-01_2022-01-06 prs stats --org=RedHatOfficial --from=2022-01-01 --to=2022-01-06 --ignore-unknown`.strip - expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0% of contributions (0/1) were made by 0 external contributors (0/1).' + expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0.0% of contributions (0/1) were made by 0 external contributors (0/1).' end it 'parses dates' do output = `"#{project}" --no-cache --vcr-cassette-name=search/RedHatOfficial/prs_2022-01-01_2022-01-06 prs stats --org=RedHatOfficial --from=2022-01-01 --to="january sixth 2022" --ignore-unknown`.strip - expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0% of contributions (0/1) were made by 0 external contributors (0/1).' + expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0.0% of contributions (0/1) were made by 0 external contributors (0/1).' end it 'returns contributors for the default org' do output = `"#{project}" --no-cache --vcr-cassette-name=search/opensearch-project/prs_2022-01-01_2022-01-06 prs stats --from=2022-01-01 --to=2022-01-06 --ignore-unknown`.strip - expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0% of contributions (0/104) were made by 0 external contributors (0/45).' + expect(output).to include 'Between 2022-01-01 and 2022-01-06, 0.0% of contributions (0/104) were made by 0 external contributors (0/45).' end it 'returns contributors for a single repo' do output = `"#{project}" --no-cache --vcr-cassette-name=search/aws/aws-cli/prs_2022-10-01_2022-10-24 prs stats --repo=aws/aws-cli --from=2022-10-01 --to=2022-10-24 --ignore-unknown`.strip - expect(output).to include 'Between 2022-10-01 and 2022-10-24, 0% of contributions (0/12) were made by 0 external contributors (0/5).' + expect(output).to include 'Between 2022-10-01 and 2022-10-24, 0.0% of contributions (0/12) were made by 0 external contributors (0/5).' end end end