Last active
February 14, 2025 12:55
-
-
Save jonico/f002e0ae5cb37ad2019242b02b7b15fb to your computer and use it in GitHub Desktop.
Count all unique committers in the last 90 days on GitHub Enterprise Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghe-console -y <<'ENDSCRIPT' | |
ActiveRecord::Base.connected_to(role: :reading) do | |
puts "Version 0.2.0" | |
emails = Set.new | |
start_time = 90.days.ago.beginning_of_day | |
Repository.where(active: true).find_each do |repo| | |
Push | |
.where(repository: repo) | |
.where("created_at >= ?", start_time) | |
.find_each do |push| | |
push.commits_pushed.each do |commit| | |
commit.author_emails.each do |email| | |
emails << email unless UserEmail.belongs_to_a_bot?(email) | |
end | |
end | |
end | |
end | |
users = Set.new | |
emails.each_slice(1000) do |batch| | |
emails_to_users_hash = User.find_by_emails(batch) | |
active_users = emails_to_users_hash.values.select do |user| | |
!(user.disabled? || user.suspended?) | |
end | |
users.merge(active_users) | |
end | |
puts "Committers in the past 90d: #{users.size}" | |
end | |
ENDSCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Count all the unique committers in the last 90 days on GitHub Enterprise Server, I could count them on the fingers of one hand