Skip to content

Commit

Permalink
schema.org properties for funders. #343
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 3, 2019
1 parent d353c0e commit 56c9226
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/graphql/types/funder_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/organization_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 56c9226

Please sign in to comment.