Skip to content

Commit

Permalink
Add rake task and logging. Chomp off newlines from ids
Browse files Browse the repository at this point in the history
  • Loading branch information
bbpennel committed Nov 10, 2023
1 parent 89bc0ef commit 9fc7776
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/services/tasks/group_permission_remediation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/remediate_group_permissions.rake
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9fc7776

Please sign in to comment.