-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Fenner
committed
Oct 4, 2019
1 parent
f08f855
commit 995f51e
Showing
13 changed files
with
130 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/graphql/types/organization_researcher_connection_with_meta_type.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class PersonConnectionWithMetaType < BaseConnection | ||
edge_type(PersonEdgeType) | ||
field_class GraphQL::Cache::Field | ||
|
||
field :publication_connection_count, Integer, null: false, cache: true | ||
field :dataset_connection_count, Integer, null: false, cache: true | ||
field :software_connection_count, Integer, null: false, cache: true | ||
field :organization_connection_count, Integer, null: false, cache: true | ||
|
||
def publication_connection_count | ||
Event.query(nil, citation_type: "Person-ScholarlyArticle").results.total | ||
end | ||
|
||
def dataset_connection_count | ||
Event.query(nil, citation_type: "Dataset-Person").results.total | ||
end | ||
|
||
def software_connection_count | ||
Event.query(nil, citation_type: "Person-SoftwareSourceCode").results.total | ||
end | ||
|
||
def organization_connection_count | ||
Event.query(nil, citation_type: "Organization-Person").results.total | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class PersonEdgeType < GraphQL::Types::Relay::BaseEdge | ||
node_type(PersonType) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
class PersonType < BaseObject | ||
description "A person." | ||
|
||
field :id, ID, null: true, description: "The ORCID ID of the person." | ||
field :name, String, null: true, description: "The name of the person." | ||
field :given_name, String, null: true, hash_key: "given_names", description: "Given name. In the U.S., the first name of a Person." | ||
field :family_name, String, null: true, description: "Family name. In the U.S., the last name of an Person." | ||
|
||
field :datasets, PersonDatasetConnectionWithMetaType, null: true, description: "Authored datasets", connection: true, max_page_size: 100 do | ||
argument :first, Int, required: false, default_value: 25 | ||
end | ||
|
||
field :publications, PersonPublicationConnectionWithMetaType, null: true, description: "Authored publications", connection: true, max_page_size: 100 do | ||
argument :first, Int, required: false, default_value: 25 | ||
end | ||
|
||
field :softwares, PersonSoftwareConnectionWithMetaType, null: true, description: "Authored software", connection: true, max_page_size: 100 do | ||
argument :first, Int, required: false, default_value: 25 | ||
end | ||
|
||
def id | ||
object.uid ? "https://orcid.org/#{object.uid}" : object.id | ||
end | ||
|
||
def name | ||
object.name | ||
end | ||
|
||
def datasets(**args) | ||
ids = Event.query(nil, obj_id: https_to_http(object.uid || object.id), citation_type: "Dataset-Person").results.to_a.map do |e| | ||
doi_from_url(e.subj_id) | ||
end | ||
ElasticsearchLoader.for(Doi).load_many(ids) | ||
end | ||
|
||
def publications(**args) | ||
ids = Event.query(nil, obj_id: https_to_http(object.uid || object.id), citation_type: "Person-ScholarlyArticle").results.to_a.map do |e| | ||
doi_from_url(e.subj_id) | ||
end | ||
ElasticsearchLoader.for(Doi).load_many(ids) | ||
end | ||
|
||
def softwares(**args) | ||
ids = Event.query(nil, obj_id: https_to_http(object.uid || object.id), citation_type: "Person-SoftwareSourceCode").results.to_a.map do |e| | ||
doi_from_url(e.subj_id) | ||
end | ||
ElasticsearchLoader.for(Doi).load_many(ids) | ||
end | ||
|
||
def https_to_http(url) | ||
orcid = orcid_from_url(url) | ||
return nil unless orcid.present? | ||
|
||
"https://orcid.org/#{orcid}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters