Closed jillpe closed 10 months ago
What do you want this to look like? (Do you want to provide the file name and it runs the script in the UI? If so, who has permission to do that?)
This may be helpful to reference.
I drafted this up waiting for a build. Maybe something like this will work? NOTE: I DID NOT TEST THIS
TODO: test on staging. (Note: You may need to update the cname in the script)
Create several works, upload each file and set them as their thumbnail:
After running the script, these works should no longer be attached to the works.
namespace :hyku do
desc "Delete specific thumbnails for dickinson account"
task delete_dickinson_placeholder_thumbnails: :environment do
account_cname = "dickinson.hykucommons.org"
Account.find_each do |account|
next unless account.cname == account_cname
begin
switch!(account.cname)
puts "********************** switched to #{account.cname} **********************"
Hyrax.config.curation_concerns.each do |cc|
next if cc.count.zero?
puts "********************** checking #{cc}s **********************"
cc.find_each do |work|
if work.thumbnail && (work.thumbnail.title == "HykuCommonsPlaceholder.pdf" || work.thumbnail.title == "hykuplaceholderarchives.pdf")
work.thumbnail.destroy(eradicate: true)
puts "Deleted thumbnail for #{work.id}"
next
end
end
puts "********************** updated #{cc}s **********************"
end
rescue StandardError => e
puts "********************** error: #{e} **********************"
next
end
end
end
end
@ndroark I don't think one requires your review. Is it ok to deploy to prod?
Tested on: Staging
Create several works, upload each file and set them as their thumbnail:
After running the script, these works should no longer be attached to the works.
Note: In this case, I set the ENV var in staging so that it would run the script against demo.commons-archive.org instead of dickinson.hykucommons.org
I am seeing some works in Dickinson that still have the file, e.g. https://dickinson.hykucommons.org/concern/generic_works/933487b5-287d-409d-ad3d-1a221a6778f8?locale=en
@ndroark We did not actually run the script at the time, but i just finished running it, can you check now?
I was wondering if that was the case. Looks like the file is removed, but on search results I'm seeing a broken link instead of the generic thumbnail. My guess is that the next reindex will take care of that?
hmmm that's interesting, i'm not seeing the broken thumbs
can you check it cache cleared just in case?
Summary
Want to remove "HykuCommonsPlaceholder.pdf" and "hykuplaceholderarchives.pdf" from dickinson.hykucommons.org
Pals is okay if this is a one time script that SoftServ runs.
Acceptance Criteria
Testing Instructions
Create several works, upload each file and set them as their thumbnail:
hykuplaceholderarchives.pdf
HykuCommonsPlaceholder.pdf
After running the script, these works should no longer be attached to the works.