diff --git a/app/services/tasks/group_permission_remediation_service.rb b/app/services/tasks/group_permission_remediation_service.rb index 73a3e5bf7..f40644404 100644 --- a/app/services/tasks/group_permission_remediation_service.rb +++ b/app/services/tasks/group_permission_remediation_service.rb @@ -15,11 +15,15 @@ def initialize(id_list_file, admin_set_id) def run work_id_list.each do |work_id| + start_time = Time.now + work_id = work_id.chomp work = ActiveFedora::Base.find(work_id) + Rails.logger.info("Remediating groups for #{work_id}") work.update permissions_attributes: group_permissions work.file_sets.each do |file_set| file_set.update permissions_attributes: group_permissions end + Rails.logger.info("Completed remediation of #{work_id} in #{Time.now - start_time}") end end diff --git a/lib/tasks/remediate_group_permissions.rake b/lib/tasks/remediate_group_permissions.rake new file mode 100644 index 000000000..ab7015af9 --- /dev/null +++ b/lib/tasks/remediate_group_permissions.rake @@ -0,0 +1,6 @@ +# frozen_string_literal: true +desc 'Remediate missing group permission assignments based on permissions of an admin set' +task :remediate_group_permissions, [:id_list_file, :admin_set_id] => [:environment] do |_t, args| + Rails.logger.warn('Prepapring to run GroupPermissionRemediationService') + Tasks::GroupPermissionRemediationService.run(args[:id_list_file], args[:admin_set_id]) +end