From 18f3d3160165e1e248c019fd2114803d52ce4028 Mon Sep 17 00:00:00 2001 From: kjgarza Date: Mon, 10 Feb 2020 16:52:05 +0100 Subject: [PATCH] typing results correctly --- app/controllers/concerns/metrics_helper.rb | 2 ++ app/queries/events_query.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/metrics_helper.rb b/app/controllers/concerns/metrics_helper.rb index ec71c1b98..bc398a7ed 100644 --- a/app/controllers/concerns/metrics_helper.rb +++ b/app/controllers/concerns/metrics_helper.rb @@ -25,6 +25,8 @@ def get_person_metrics(orcid) end def get_person_dois(orcid) + return [] if orcid.blank? + Event.query(nil, page: { size: 300 }, source_id: "datacite-orcid-auto-update", obj_id: "https://orcid.org/#{orcid}").results.to_a.map do |e| doi_from_url(e.subj_id) end diff --git a/app/queries/events_query.rb b/app/queries/events_query.rb index 930a7e61c..0a4e16237 100644 --- a/app/queries/events_query.rb +++ b/app/queries/events_query.rb @@ -57,7 +57,7 @@ def citations_right_query(dois, pids) end def citations(dois) - return nil if dois.blank? + return [] if dois.blank? pids = dois.split(",").map do |doi| Event.new.normalize_doi(doi) @@ -156,7 +156,7 @@ def downloads_histogram(doi) end def views_and_downloads(dois) - return {} if dois.blank? + return [] if dois.blank? query = "(relation_type_id:unique-dataset-requests-regular AND source_id:datacite-usage) OR (relation_type_id:unique-dataset-investigations-regular AND source_id:datacite-usage)" results = Event.query(query, doi: dois, aggregations: "multiple_usage_count_aggregation", page: { size: 1, cursor: [] }).response.aggregations