Created
September 19, 2022 19:37
-
-
Save malantin/90d4b9d4e08b8694340f834074303bda to your computer and use it in GitHub Desktop.
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
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