From 36bae66db04f25568758f6148c48cd6d248fbe72 Mon Sep 17 00:00:00 2001 From: Jess Rudder Date: Wed, 27 Nov 2019 13:43:51 -1000 Subject: [PATCH] Simplify and add some output --- .../remove_classroom_users_without_github_org_access.rake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/tasks/remove_classroom_users_without_github_org_access.rake b/lib/tasks/remove_classroom_users_without_github_org_access.rake index d9457174dc..6e84d497a8 100644 --- a/lib/tasks/remove_classroom_users_without_github_org_access.rake +++ b/lib/tasks/remove_classroom_users_without_github_org_access.rake @@ -3,15 +3,15 @@ # Checks if classroom admins have access to the associated GitHub organization. If not # the admin is removed from the classroom task :remove_classroom_users_without_github_org_access do - User.find_in_batches(batch_size: 250) do |group, batch| - puts "Processing group ##{batch}" + User.find_in_batches(batch_size: 250).with_index do |group, batch| + puts "Processing batch ##{batch}" group.each do |user| github_org_ids = user.organizations.pluck(:github_id).uniq next unless github_org_ids.any? github_org_ids.each do |gh_id| github_org = GitHubOrganization.new(user.github_client, gh_id) - next unless github_org.admin?(user.github_user.login) + next if github_org.admin?(user.github_login) payload = { "action": "member_removed", @@ -19,8 +19,8 @@ task :remove_classroom_users_without_github_org_access do "organization": { "id": gh_id } } + puts "Removing #{user.github_login} from org with id ##{gh_id}" OrganizationEventJob.perform_later(payload) - end end end end