Skip to content

Commit

Permalink
Merge pull request #272 from datacite/feature_delete_byprefix
Browse files Browse the repository at this point in the history
adding delete by prefix rake tasks
  • Loading branch information
kjgarza authored May 21, 2019
2 parents e15ee84 + d4b26a9 commit 45c091b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,15 @@ def self.delete_test_dois(from_date: nil)
end
end

#to be used after DOIS transfer to another RA
def self.delete_dois_by_prefix(prefix)
collection.where("doi LIKE ?", prefix).find_each do |d|
logger = Logger.new(STDOUT)
logger.info "Deleted #{d.doi}, last updated #{d.updated.iso8601}."
d.destroy
end
end

# register DOIs in the handle system that have not been registered yet
# providers ethz and europ register their DOIs in the handle system themselves and are ignored
def self.set_handle
Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ namespace :doi do
Doi.delete_test_dois(from_date: from_date)
end

desc 'Delete DOIs with by prefix'
task :delete_test_dois => :environment do
prefix = ENV['PREFIX_TO_DELETE']
Doi.delete_dois_by_prefix(prefix) if prefix.present?
end

desc 'Migrates landing page data handling camelCase changes at same time'
task :migrate_landing_page => :environment do
Doi.migrate_landing_page
Expand Down

0 comments on commit 45c091b

Please sign in to comment.