Created
September 19, 2022 19:42
-
-
Save malantin/4b04312f776ff8a40c0d93ff5a373baa 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
admin@malantin-009c14c14d9d1b660-ghe-test-org:~$ ghe-console -y < ghas.rb | |
Loading production environment | |
Loading config/console.rb | |
Switch to inspect mode. | |
<ctiveRecord::Base.connected_to(role: :reading) do | |
GitHub[production] (main):002:1* puts "Version 1.2.2" | |
GitHub[production] (main):003:1> emails = Set.new | |
< start_time = 90.days.ago.beginning_of_day | |
<tory.where(active: true).find_in_batches do |batch| | |
< Configurable.try(:preload_configuration, batch) | |
GitHub[production] (main):007:2> batch.each do |repo| | |
GitHub[production] (main):008:3* Push | |
GitHub[production] (main):009:3> .where(repository: repo) | |
< .where("created_at >= ?", start_time) | |
< .find_in_batches do |push_batch| | |
< push_batch.each do |push| | |
GitHub[production] (main):013:5* begin | |
< push.commits_pushed.each do |commit| | |
< commit.author_emails.each do |email| | |
< << email unless UserEmail.belongs_to_a_bot?(email) | |
GitHub[production] (main):017:8> end | |
GitHub[production] (main):018:7> end | |
<es, GitRPC::SymlinkDisallowed, GitRPC::Timeout => e | |
< commit: '#{push.after}'. #{e.class}: #{e.message}" | |
GitHub[production] (main):021:6> end | |
GitHub[production] (main):022:5> end | |
GitHub[production] (main):023:4> end | |
GitHub[production] (main):024:3> end | |
GitHub[production] (main):025:2> end | |
GitHub[production] (main):026:1> users = Set.new | |
GitHub[production] (main):027:1> emails.each_slice(1000) do |batch| | |
< emails_to_users_hash = User.find_by_emails(batch) | |
<sers = emails_to_users_hash.values.select do |user| | |
< !(user.disabled? || user.suspended?) | |
GitHub[production] (main):031:3> end | |
GitHub[production] (main):032:2> users.merge(active_users) | |
GitHub[production] (main):033:2> end | |
<uts "All committers in the past 90d: #{users.size}" | |
< users.each { |n| puts "username: #{n.login}"} | |
GitHub[production] (main):036:1> end | |
Version 1.2.2 | |
All committers in the past 90d: 1 | |
username: ghe-admin | |
=> | |
#<Set: | |
{#<User id: 4, login: "ghe-admin", created_at: [FILTERED], updated_at: [FILTERED], remember_token: nil, remember_token_expires_at: nil, wants_email: [FILTERED], disabled: [FILTERED], plan: nil, billed_on: nil, upgrade_ignore: nil, upgrade_accept: nil, gh_role: [FILTERED], billing_attempts: [FILTERED], spammy: [FILTERED], last_ip: [FILTERED], plan_duration: nil, billing_extra: nil, gift: nil, type: "User", last_read_broadcast_id: nil, raw_data: [FILTERED], referral_code: nil, billing_type: [FILTERED], suspended_at: nil, organization_billing_email: nil, gravatar_email: [FILTERED], time_zone_name: [FILTERED], restrict_oauth_applications: nil, spammy_reason: nil, seats: [FILTERED], split_diff_preferred: [FILTERED], require_email_verification: [FILTERED], warn_private_email: [FILTERED], primary_language_name_id: nil, analytics_tracking_id: nil, report_third_party_analytics: [FILTERED], source_login: nil, migration_id: nil, ofac_flagged: [FILTERED], weak_password_check_result: nil, color_mode: [FILTERED], light_theme: [FILTERED], dark_theme: [FILTERED], pinned_api_version: nil, private_profile: [FILTERED], business_id: [FILTERED]>}> | |
GitHub[production] (main):037:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment