-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🧹 Add task to remove placeholder file sets #938
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be an auto page size of 10,000 records. Meaning you might need to run this multiple times.
This commit will add a rake task to remove placeholder file sets from the Dickinson tenant. To test, set an environment variable with whatever cname you want to use and run the task. For example: ```sh REMOVE_PLACEHOLDER_FILE_SETS_FROM="dev.hyku.test" rake hyku:remove_placeholder_file_sets ``` Ref: - #912
14ebf96
to
162b148
Compare
next unless account.cname == account_cname | ||
|
||
begin | ||
switch!(account.cname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it that this task is dynamic and reusable + the query approach. well done! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kirkkwang A few more thoughts:
This works but after going through QA it was kind of a pain having to remember to set the env var to test what I needed.
I think it would be nice if we could pass the cname when calling the rake task command. I also think the file name is a misnomer if we want this to be more dynamic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this but maybe something like this?
# rename file to lib/tasks/remove_placeholders.rake
namespace :hyku do
desc "Remove Hyku Commons placeholder file sets from tenants"
task :remove_placeholder_file_sets, [:cnames] => :environment do |t, args|
cnames = args[:cnames].split(',')
cnames.each do |cname|
account = Account.find_by(cname: cname)
next unless account
begin
switch!(account.cname)
puts "********************** switched to #{account.cname} **********************"
file_set_titles = ["HykuCommonsPlaceholder.pdf", "hykuplaceholderarchives.pdf"]
query = file_set_titles.map { |title| "title_tesim:\"#{title}\"" }.join(" OR ")
file_sets = FileSet.where(query)
file_sets.each { |file_set| file_set.destroy(eradicate: true) }
rescue StandardError => e
puts "********************** error: #{e} **********************"
end
end
end
end
Then we could call the rake task and pass it an array of cnames
This commit will add a rake task to remove placeholder file sets from the Dickinson tenant. To test, set an environment variable with whatever cname you want to use and run the task. For example:
REMOVE_PLACEHOLDER_FILE_SETS_FROM="dev.hyku.test" rake hyku:remove_placeholder_file_sets
Ref:
Notes
This should only be run once and future file sets of the placeholder pdf should not appear.
Tested locally and it worked for me.