From 00952622c18fb69a8dee95752edf94ff35fbc6da Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 29 Sep 2020 08:30:46 +0200 Subject: [PATCH] handle missing contributors. #647 --- app/graphql/types/doi_item.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index 223f1358d..8e8e0704e 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -282,7 +282,7 @@ def fields_of_science end def creators(**args) - Array.wrap(object.creators[0...args[:first]]).map do |c| + Array.wrap(object.creators)[0...args[:first]].map do |c| Hashie::Mash.new( "id" => c.fetch("nameIdentifiers", []).find { |n| %w(ORCID ROR).include?(n.fetch("nameIdentifierScheme", nil)) }.to_h.fetch("nameIdentifier", nil), "name_type" => c.fetch("nameType", nil), @@ -297,7 +297,7 @@ def creators(**args) end def contributors(**args) - contrib = Array.wrap(object.contributors[0...args[:first]]) + contrib = Array.wrap(object.contributors)[0...args[:first]] contrib = contrib.select { |c| c["contributorType"] == args[:contributor_type] } if args[:contributor_type].present? contrib.map do |c| Hashie::Mash.new(