Skip to content

Commit

Permalink
follow established patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
bkiahstroud committed Apr 24, 2024
1 parent 8e82c18 commit 285285d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/services/ams/asset_destroyer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'ruby-progressbar'

module AMS
class AssetDestroyer
attr_accessor :asset_ids, :user_email, :logger
Expand All @@ -10,8 +12,10 @@ def initialize(asset_ids: [], user_email: nil)

def destroy(asset_ids)
logger.info "Initiating destruction sequence for #{asset_ids.count} Assets..."
progressbar = ProgressBar.create(total: asset_ids.size, format: "Destroying Assets: %a %e %c/%C %P%")
Array(asset_ids).each do |asset_id|
destroy_asset_by_id asset_id
progressbar.increment
end
end

Expand Down Expand Up @@ -65,8 +69,9 @@ def destroy_in_postgres(asset_id)
.with_step_args('work_resource.delete' => { user: user },
'work_resource.delete_all_file_sets' => { user: user })
.call(asset_resource).value!
rescue Valkyrie::Persistence::ObjectNotFoundError
puts "No AssetResource found with ID #{asset_id}"
logger.debug "AssetResource '#{asset_id}' (and children) destroyed."
rescue => e
error_rescue(e, 'AssetResource', asset_id)
end

def actor
Expand Down

0 comments on commit 285285d

Please sign in to comment.