Skip to content

Commit

Permalink
set minted state for ethz dois. #202
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Feb 10, 2019
1 parent 3ff0c42 commit 4283492
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
23 changes: 23 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,29 @@ def self.set_url
end
end

def self.set_minted
logger = Logger.new(STDOUT)

response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 0, cursor: 1 })
logger.info "#{response.results.total} draft DOIs from provider ETHZ found in the database."

if response.results.total > 0
# walk through results using cursor
prev_cursor = 0
cursor = 1

while cursor > prev_cursor do
response = Doi.query("url:* +provider_id:ethz +aasm_state:draft", page: { size: 1000, cursor: cursor })
prev_cursor = cursor
cursor = Array.wrap(response.results.results.last[:sort]).first

response.results.results.each do |d|
UrlJob.perform_later(d.doi)
end
end
end
end

# save to metadata table when xml has changed
def save_metadata
metadata.build(doi: self, xml: xml, namespace: schema_version) if xml.present? && xml_changed?
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/_version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Lupo
class Application
VERSION = "2.3.27"
VERSION = "2.3.28"
end
end
5 changes: 5 additions & 0 deletions lib/tasks/doi.rake
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ namespace :doi do
Doi.set_handle
end

desc 'Set minted'
task :set_minted => :environment do
Doi.set_minted
end

desc 'Delete DOIs with test prefix older than one month'
task :delete_test_dois => :environment do
from_date = ENV['FROM_DATE'] || Time.zone.now - 1.month
Expand Down

0 comments on commit 4283492

Please sign in to comment.