From b12452545a4b7f7583d504b5b8feb4de15e5ffaf Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Mon, 7 Oct 2019 00:08:30 +0200 Subject: [PATCH] enable filtering update by citation types --- app/models/event.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 9cf905a30..c346403c3 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -453,15 +453,16 @@ def self.update_registrant(options={}) size = (options[:size] || 1000).to_i cursor = (options[:cursor] || []) # ra = options[:ra] || "crossref" - source_id = "datacite-crossref,crossref" + source_id = options[:source_id] || "datacite-crossref,crossref" + citation_type = options[:citation_type] || "Dataset-ScholarlyArticle" - response = Event.query(nil, source_id: source_id, page: { size: 1, cursor: cursor }) + response = Event.query(nil, 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, page: { size: size, cursor: cursor }) + response = Event.query(nil, 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]}."