Skip to content

Instantly share code, notes, and snippets.

@malantin
Created September 19, 2022 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malantin/90d4b9d4e08b8694340f834074303bda to your computer and use it in GitHub Desktop.
Save malantin/90d4b9d4e08b8694340f834074303bda to your computer and use it in GitHub Desktop.
ActiveRecord::Base.connected_to(role: :reading) do
puts "Version 1.2.2"
emails = Set.new
start_time = 90.days.ago.beginning_of_day
Repository.where(active: true).find_in_batches do |batch|
Configurable.try(:preload_configuration, batch)
batch.each do |repo|
Push
.where(repository: repo)
.where("created_at >= ?", start_time)
.find_in_batches do |push_batch|
push_batch.each do |push|
begin
push.commits_pushed.each do |commit|
commit.author_emails.each do |email|
emails << email unless UserEmail.belongs_to_a_bot?(email)
end
end
rescue GitRPC::BadObjectState, GitRPC::BadGitmodules, GitRPC::SymlinkDisallowed, GitRPC::Timeout => e
puts "Git error while fetching commit: '#{push.after}'. #{e.class}: #{e.message}"
end
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 "All committers in the past 90d: #{users.size}"
users.each { |n| puts "username: #{n.login}"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment