From 41c51165ca9887bb24c82ffcb653e7050fda60d0 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 1 May 2024 09:23:03 -0400 Subject: [PATCH] Fix unique maintainers (#83) * Fix: consider maintainers once for stats. Signed-off-by: dblock * Display maintainer to repo. Signed-off-by: dblock --------- Signed-off-by: dblock --- bin/commands/maintainers.rb | 5 +++++ lib/github/maintainers.rb | 8 ++++---- lib/github/repos.rb | 13 +++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/commands/maintainers.rb b/bin/commands/maintainers.rb index a1967eb..6439f53 100644 --- a/bin/commands/maintainers.rb +++ b/bin/commands/maintainers.rb @@ -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})" diff --git a/lib/github/maintainers.rb b/lib/github/maintainers.rb index cda6a43..a5a78e6 100644 --- a/lib/github/maintainers.rb +++ b/lib/github/maintainers.rb @@ -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 @@ -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) diff --git a/lib/github/repos.rb b/lib/github/repos.rb index 9eb845d..1521a83 100644 --- a/lib/github/repos.rb +++ b/lib/github/repos.rb @@ -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