Skip to content

Instantly share code, notes, and snippets.

@jonico
Last active February 14, 2025 12:55
Show Gist options
  • Save jonico/f002e0ae5cb37ad2019242b02b7b15fb to your computer and use it in GitHub Desktop.
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
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
@zaxar13
Copy link

zaxar13 commented Feb 14, 2025

Count all the unique committers in the last 90 days on GitHub Enterprise Server, I could count them on the fingers of one hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment