Skip to content

Commit

Permalink
Merge pull request #554 from datacite/client-id-downcase
Browse files Browse the repository at this point in the history
Use correct case for client-id
  • Loading branch information
Martin Fenner authored Jun 3, 2020
2 parents 6a9954f + e4b13b5 commit ca4bc7a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1840,20 +1840,20 @@ def self.transfer(options={})
query = options[:query] || "*"
size = (options[:size] || 1000).to_i

response = Doi.query(nil, client_id: options[:client_id], page: { size: 1, cursor: [] })
response = Doi.query(nil, client_id: options[:client_id].downcase, page: { size: 1, cursor: [] })
Rails.logger.info "[Transfer] #{response.results.total} DOIs found for client #{options[:client_id]}."

if options[:client_id] && options[:client_target_id] && response.results.total > 0
# walk through results using cursor
cursor = []

while response.results.results.length.positive? do
response = Doi.query(nil, client_id: options[:client_id], page: { size: size, cursor: cursor })
response = Doi.query(nil, client_id: options[:client_id].downcase, page: { size: size, cursor: cursor })
break unless response.results.results.length.positive?

Rails.logger.info "[Transfer] Transferring #{response.results.results.length} DOIs starting with _id #{response.results.to_a.first[:_id]}."
cursor = response.results.to_a.last[:sort]
Rails.logger.info cursor
Rails.logger.info "[Transfer] Next cursor for transfer is #{cursor.inspect}."
response.results.results.each do |d|
TransferJob.perform_later(d.doi, client_target_id: options[:client_target_id])
end
Expand Down

0 comments on commit ca4bc7a

Please sign in to comment.