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

Commit a3865bd

Browse files
committed
Simplify and add some output
1 parent 3d00951 commit a3865bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/tasks/remove_classroom_users_without_github_org_access.rake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
# Checks if classroom admins have access to the associated GitHub organization. If not
44
# the admin is removed from the classroom
55
task :remove_classroom_users_without_github_org_access do
6-
User.find_in_batches(batch_size: 250) do |group, batch|
7-
puts "Processing group ##{batch}"
6+
User.find_in_batches(batch_size: 250).with_index do |group, batch|
7+
puts "Processing batch ##{batch}"
88
group.each do |user|
99
github_org_ids = user.organizations.pluck(:github_id).uniq
1010
next unless github_org_ids.any?
1111

1212
github_org_ids.each do |gh_id|
1313
github_org = GitHubOrganization.new(user.github_client, gh_id)
14-
next unless github_org.admin?(user.github_user.login)
14+
next if github_org.admin?(user.github_login)
1515

1616
payload = {
1717
"action": "member_removed",
1818
"membership": { "user": { "id": user.github_user.id } },
1919
"organization": { "id": gh_id }
2020
}
2121

22+
puts "Removing #{user.github_login} from org with id ##{gh_id}"
2223
OrganizationEventJob.perform_later(payload)
2324
end
2425
end

0 commit comments

Comments
 (0)