-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup/stop accessioning rake tasks (#4598)
* cleanup/stop accessioning rake tasks * change to logic of preservationIngestWF check; logging changes * move all rake task logic to CleanupService and add tests
- Loading branch information
Showing
3 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
# rubocop: disable Metrics/BlockLength | ||
namespace :cleanup do | ||
# Stop accessioning in progress for the supplied druid (if possible). | ||
# bundle exec rake cleanup:stop_accessioning['druid:ab123bc4567'] | ||
# bundle exec rake cleanup:stop_accessioning['druid:ab123bc4567',:dryrun] # shows output but does not actually delete | ||
desc 'Stop Accessioning for single druid' | ||
task :stop_accessioning, [:druid, :dryrun] => :environment do |_task, args| | ||
dryrun = args[:dryrun] || false | ||
druid = args[:druid] | ||
|
||
$stdout.puts "This will completely stop accessioning for #{druid}. Are you sure? [y/n]:" | ||
raise 'Aborting' unless $stdin.gets.chomp == 'y' | ||
|
||
CleanupService.stop_accessioning(druid, '/dor/stopped', dryrun:) | ||
end | ||
|
||
# Stop accessioning in progress for multiple druids supplied in a CSV (one per line, no header) | ||
# bundle exec rake cleanup:bulk_stop_accessioning['tmp/druids.csv'] | ||
# bundle exec rake cleanup:bulk_stop_accessioning['tmp/druids.csv',:dryrun] # shows output but does not actually delete | ||
desc 'Stop Accessioning for multiple druids provided in a CSV' | ||
task :bulk_stop_accessioning, [:input_file, :dryrun] => :environment do |_task, args| | ||
input_file = args[:input_file] | ||
raise 'CSV file not found' unless File.exist? input_file | ||
|
||
dryrun = args[:dryrun] || false | ||
$stdout.puts '*** DRY RUN - NO ACTIONS WILL BE PERFORMED' if dryrun | ||
|
||
rows = CSV.read(input_file) | ||
$stdout.puts "This will completely stop accessioning for #{rows.size} objects. Are you sure? [y/n]:" | ||
raise 'Aborting' unless $stdin.gets.chomp == 'y' | ||
|
||
rows.each do |row| | ||
druid = row.first | ||
$stdout.puts druid | ||
|
||
begin | ||
CleanupService.stop_accessioning(druid, '/dor/stopped', dryrun:) | ||
rescue StandardError => e | ||
$stdout.puts "Error stopping accessioning for #{druid}: #{e.message} #{e.backtrace.join("\n")}" | ||
end | ||
end | ||
end | ||
end | ||
# rubocop: enable Metrics/BlockLength |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters