Skip to content

Commit

Permalink
Fix unique maintainers (#83)
Browse files Browse the repository at this point in the history
* Fix: consider maintainers once for stats.

Signed-off-by: dblock <[email protected]>

* Display maintainer to repo.

Signed-off-by: dblock <[email protected]>

---------

Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock authored May 1, 2024
1 parent 4716e3f commit 41c5116
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions bin/commands/maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class Commands
puts "#{repo.html_url}: #{repo.maintainers.all_external} (#{repo.maintainers.all_external_unique_percent}%, #{repo.maintainers.all_external_unique_count}/#{repo.maintainers.unique_count})"
end

puts "\n# External Maintainers (Repos)\n"
repos.external_maintainers.each_pair do |maintainer, repos_maintained|
puts "#{maintainer}: #{repos_maintained.map(&:html_url).join(', ')}"
end

# GitHub::Maintainers::ALL_EXTERNAL.each do |bucket|
# repos.maintained[bucket]&.sort_by(&:name)&.each do |repo|
# puts "#{repo.html_url}: #{repo.maintainers.all_external} (#{repo.maintainers.all_external_unique_percent}%, #{repo.maintainers.all_external_unique_count}/#{repo.maintainers.unique_count})"
Expand Down
8 changes: 4 additions & 4 deletions lib/github/maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def buckets
def all_external
ALL_EXTERNAL.map do |bucket|
buckets[bucket]
end.flatten.compact
end.flatten.uniq.compact
end

def all_external_unique_percent
Expand All @@ -31,13 +31,13 @@ def all_external_unique_percent
end

def unique_count
buckets.values.map(&:size).sum
buckets.values.flatten.uniq.size
end

def all_external_unique_count
ALL_EXTERNAL.map do |bucket|
buckets[bucket]&.size || 0
end.sum
buckets[bucket]
end.compact.flatten.uniq.size
end

def each_pair(&_block)
Expand Down
13 changes: 13 additions & 0 deletions lib/github/repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ def externally_maintained
end
end

def external_maintainers
@external_maintainers ||= begin
all = {}
externally_maintained.each do |repo|
repo.maintainers.all_external.each do |maintainer|
all[maintainer] ||= []
all[maintainer] << repo
end
end
all
end
end

def all_external_maintained_size
Maintainers::ALL_EXTERNAL.map do |bucket|
maintained[bucket]&.size || 0
Expand Down

0 comments on commit 41c5116

Please sign in to comment.