Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Simplify and add some output
Browse files Browse the repository at this point in the history
  • Loading branch information
JessRudder committed Nov 27, 2019
1 parent 3d00951 commit 36bae66
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
# 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",
"membership": { "user": { "id": user.github_user.id } },
"organization": { "id": gh_id }
}

puts "Removing #{user.github_login} from org with id ##{gh_id}"
OrganizationEventJob.perform_later(payload)
end
end
end
end
Expand Down

0 comments on commit 36bae66

Please sign in to comment.