Last active
July 10, 2025 19:59
-
-
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 |
https://github.com/github/code-scanning/issues/2537 is trying to solve that, Simon is working on it now
Trying to be really careful how code is distributed - seeing lots of stale / adapted versions of this script around and ideally there's one source of truth so we can keep it updated and consistent and fix issues for all customers
@cbraynor great! let me know when its done and then I can put the official ones to use in the SE repo (or a link to the official ones)!
good
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
I also just created a script from this one that gets the committers from specific orgs based off of organization_id. I would love to do it based off of org name but couldn't figure out how.