Skip to content

Commit

Permalink
Merge pull request #540 from datacite/fields-of-science
Browse files Browse the repository at this point in the history
Support oecd fields of science
  • Loading branch information
Martin Fenner authored May 29, 2020
2 parents 8829866 + bb91f06 commit 2b754ce
Show file tree
Hide file tree
Showing 21 changed files with 394 additions and 210 deletions.
3 changes: 3 additions & 0 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def index
resource_type: params[:resource_type],
schema_version: params[:schema_version],
subject: params[:subject],
field_of_science: params[:field_of_science],
has_citations: params[:has_citations],
has_references: params[:has_references],
has_parts: params[:has_parts],
Expand Down Expand Up @@ -165,6 +166,7 @@ def index
affiliations = total.positive? ? facet_by_combined_key(response.aggregations.affiliations.buckets) : nil
# sources = total.positive? ? facet_by_key(response.aggregations.sources.buckets) : nil
subjects = total.positive? ? facet_by_key(response.aggregations.subjects.buckets) : nil
fields_of_science = total.positive? ? facet_by_key(response.aggregations.fields_of_science.subject.buckets) : nil
certificates = total.positive? ? facet_by_key(response.aggregations.certificates.buckets) : nil

link_checks_status = total.positive? ? facet_by_cumulative_year(response.aggregations.link_checks_status.buckets) : nil
Expand Down Expand Up @@ -204,6 +206,7 @@ def index
# "linkChecksDcIdentifier" => link_checks_dc_identifier,
# "linkChecksCitationDoi" => link_checks_citation_doi,
subjects: subjects,
"fieldsOfScience" => fields_of_science,
citations: citations,
views: views,
downloads: downloads,
Expand Down
409 changes: 209 additions & 200 deletions app/graphql/schema.graphql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ConferencePaperConnectionWithTotalType < BaseConnection
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :fields_of_science, [FacetType], null: true, cache: true

def total_count
object.total_count
Expand All @@ -29,4 +30,8 @@ def repositories
def affiliations
object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : []
end

def fields_of_science
object.total_count.positive? ? facet_by_combined_key(object.aggregations.fields_of_science.subject.buckets) : []
end
end
5 changes: 5 additions & 0 deletions app/graphql/types/dataset_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DatasetConnectionWithTotalType < BaseConnection
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :fields_of_science, [FacetType], null: true, cache: true

field :dataset_connection_count, Integer, null: false, cache: true
field :publication_connection_count, Integer, null: false, cache: true
Expand Down Expand Up @@ -60,4 +61,8 @@ def funder_connection_count
def organization_connection_count
@organization_connection_count ||= Event.query(nil, citation_type: "Dataset-Organization", page: { number: 1, size: 0 }).results.total
end

def fields_of_science
object.total_count.positive? ? facet_by_combined_key(object.aggregations.fields_of_science.subject.buckets) : []
end
end
5 changes: 5 additions & 0 deletions app/graphql/types/dissertation_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DissertationConnectionWithTotalType < BaseConnection
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :fields_of_science, [FacetType], null: true, cache: true

def total_count
object.total_count
Expand All @@ -29,4 +30,8 @@ def repositories
def affiliations
object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : []
end

def fields_of_science
object.total_count.positive? ? facet_by_combined_key(object.aggregations.fields_of_science.subject.buckets) : []
end
end
8 changes: 7 additions & 1 deletion app/graphql/types/doi_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -88,6 +89,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -108,6 +110,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -128,6 +131,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -148,6 +152,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -168,6 +173,7 @@ module DoiItem
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand Down Expand Up @@ -267,7 +273,7 @@ def response(**args)
# make sure no dois are returnded if there are no :ids
args[:ids] = "999" if args[:ids].blank?

Doi.query(args[:query], ids: args[:ids], funder_id: args[:funder_id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
Doi.query(args[:query], ids: args[:ids], funder_id: args[:funder_id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
end

def doi_link(url)
Expand Down
6 changes: 5 additions & 1 deletion app/graphql/types/funder_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class FunderType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -40,6 +41,7 @@ class FunderType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -57,6 +59,7 @@ class FunderType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -76,6 +79,7 @@ class FunderType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand Down Expand Up @@ -123,6 +127,6 @@ def citation_count
end

def response(**args)
Doi.query(args[:query], ids: args[:ids], funder_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
Doi.query(args[:query], ids: args[:ids], funder_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class JournalArticleConnectionWithTotalType < BaseConnection
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true
field :fields_of_science, [FacetType], null: true, cache: true

def total_count
object.total_count
Expand All @@ -29,4 +30,8 @@ def repositories
def affiliations
object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : []
end

def fields_of_science
object.total_count.positive? ? facet_by_combined_key(object.aggregations.fields_of_science.subject.buckets) : []
end
end
6 changes: 5 additions & 1 deletion app/graphql/types/member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MemberType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -56,6 +57,7 @@ class MemberType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -76,6 +78,7 @@ class MemberType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -96,6 +99,7 @@ class MemberType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand Down Expand Up @@ -176,6 +180,6 @@ def citation_count
end

def response(**args)
Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: object.member_type == "consortium" ? nil : object.uid, consortium_id: object.member_type == "consortium" ? object.uid : nil, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: object.member_type == "consortium" ? nil : object.uid, consortium_id: object.member_type == "consortium" ? object.uid : nil, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
end
end
6 changes: 5 additions & 1 deletion app/graphql/types/organization_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class OrganizationType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -40,6 +41,7 @@ class OrganizationType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -56,6 +58,7 @@ class OrganizationType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -72,6 +75,7 @@ class OrganizationType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 2
argument :after, String, required: false
end
Expand Down Expand Up @@ -131,6 +135,6 @@ def citation_count
end

def response(**args)
Doi.query(args[:query], ids: args[:ids], affiliation_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], funder_id: args[:funder_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
Doi.query(args[:query], ids: args[:ids], affiliation_id: object.id, user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], funder_id: args[:funder_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
end
end
6 changes: 5 additions & 1 deletion app/graphql/types/person_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PersonType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -40,6 +41,7 @@ class PersonType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -56,6 +58,7 @@ class PersonType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand All @@ -73,6 +76,7 @@ class PersonType < BaseObject
argument :has_versions, Int, required: false
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
end
Expand Down Expand Up @@ -115,6 +119,6 @@ def citation_count
end

def response(**args)
Doi.query(args[:query], ids: args[:ids], user_id: object[:id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
Doi.query(args[:query], ids: args[:ids], user_id: object[:id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], field_of_science: args[:field_of_science], state: "findable", page: { cursor: args[:after].present? ? Base64.urlsafe_decode64(args[:after]) : nil, size: args[:first] })
end
end
7 changes: 6 additions & 1 deletion app/graphql/types/preprint_connection_with_total_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class PreprintConnectionWithTotalType < BaseConnection
field :registration_agencies, [FacetType], null: true, cache: true
field :repositories, [FacetType], null: true, cache: true
field :affiliations, [FacetType], null: true, cache: true

field :fields_of_science, [FacetType], null: true, cache: true

def total_count
object.total_count
end
Expand All @@ -29,4 +30,8 @@ def repositories
def affiliations
object.total_count.positive? ? facet_by_combined_key(object.aggregations.affiliations.buckets) : []
end

def fields_of_science
object.total_count.positive? ? facet_by_combined_key(object.aggregations.fields_of_science.subject.buckets) : []
end
end
Loading

0 comments on commit 2b754ce

Please sign in to comment.