From 56c9226eaade3b80c5201665e395d8ec18733471 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 3 Oct 2019 22:18:13 +0200 Subject: [PATCH] schema.org properties for funders. #343 --- app/graphql/types/funder_type.rb | 13 +++++++++---- app/graphql/types/organization_type.rb | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/graphql/types/funder_type.rb b/app/graphql/types/funder_type.rb index 521f90218..b82823ac9 100644 --- a/app/graphql/types/funder_type.rb +++ b/app/graphql/types/funder_type.rb @@ -4,10 +4,10 @@ class FunderType < BaseObject description "Information about funders" field :id, ID, null: false, description: "Crossref Funder ID" - field :name, String, null: false, description: "Funder name" - field :alternate_name, [String], null: true, description: "Alternate funder names" - field :country, CountryType, null: true, description: "Country where funder is located" - field :date_modified, String, null: false, description: "Date information was last updated" + field :name, String, null: false, description: "The name of the funder." + field :alternate_name, [String], null: true, description: "An alias for the funder." + field :address, AddressType, null: true, description: "Physical address of the funder." + field :datasets, FunderDatasetConnectionWithMetaType, null: false, description: "Funded datasets", connection: true, max_page_size: 100 do argument :first, Int, required: false, default_value: 25 end @@ -21,6 +21,11 @@ class FunderType < BaseObject argument :first, Int, required: false, default_value: 25 end + def address + { "type" => "postalAddress", + "address_country" => object.country.to_h.fetch("name", nil) } + end + def datasets(**args) ids = Event.query(nil, obj_id: object[:id], citation_type: "Dataset-Funder").results.to_a.map do |e| doi_from_url(e.subj_id) diff --git a/app/graphql/types/organization_type.rb b/app/graphql/types/organization_type.rb index 70ea67456..a427b6002 100644 --- a/app/graphql/types/organization_type.rb +++ b/app/graphql/types/organization_type.rb @@ -40,7 +40,7 @@ def identifier def address { "type" => "postalAddress", - "address_country" => object.country.fetch("name", nil) } + "address_country" => object.country.to_h.fetch("name", nil) } end def datasets(**args)