diff --git a/app/models/event.rb b/app/models/event.rb index c346403c3..e36d91f60 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -453,16 +453,17 @@ def self.update_registrant(options={}) size = (options[:size] || 1000).to_i cursor = (options[:cursor] || []) # ra = options[:ra] || "crossref" - source_id = options[:source_id] || "datacite-crossref,crossref" + source_id = options[:source_id] || "datacite-crossref" citation_type = options[:citation_type] || "Dataset-ScholarlyArticle" + query = options[:query] || "registrant_id:*crossref.citations" - response = Event.query(nil, source_id: source_id, citation_type: citation_type, page: { size: 1, cursor: cursor }) + response = Event.query(query, source_id: source_id, citation_type: citation_type, page: { size: 1, cursor: cursor }) logger.info "[Update] #{response.results.total} events for sources #{source_id}." # walk through results using cursor if response.results.total > 0 while response.results.results.length > 0 do - response = Event.query(nil, source_id: source_id, citation_type: citation_type, page: { size: size, cursor: cursor }) + response = Event.query(query, source_id: source_id, citation_type: citation_type, page: { size: size, cursor: cursor }) break unless response.results.results.length > 0 logger.info "[Update] Updating #{response.results.results.length} #{source_id} events starting with _id #{response.results.to_a.first[:_id]}."