Skip to content

Commit

Permalink
Don't make maintainers globally unique. (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored Mar 29, 2024
1 parent ad44392 commit 4716e3f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/github/buckets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/github/maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/github/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions spec/project/commands/pr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4716e3f

Please sign in to comment.