Skip to content

Commit

Permalink
adding missing fields for person
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 4, 2019
1 parent 0d8e3b1 commit 76a2288
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/graphql/types/person_dataset_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class PersonDatasetConnectionWithMetaType < BaseConnection
edge_type(EventDataEdgeType, edge_class: EventDataEdge)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true

def total_count
Event.query(nil, obj_id: https_to_http(object.parent.uid ? "https://orcid.org/#{object.parent.uid}" : nil || object.parent[:id]), citation_type: "Dataset-Person").results.total
end

def https_to_http(url)
uri = Addressable::URI.parse(url)
uri.scheme = "http" if uri.present?
uri.to_s
end
end
18 changes: 18 additions & 0 deletions app/graphql/types/person_publication_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class PersonPublicationConnectionWithMetaType < BaseConnection
edge_type(EventDataEdgeType, edge_class: EventDataEdge)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true

def total_count
Event.query(nil, obj_id: https_to_http(object.parent.uid ? "https://orcid.org/#{object.parent.uid}" : nil || object.parent[:id]), citation_type: "Person-ScholarlyArticle").results.total
end

def https_to_http(url)
uri = Addressable::URI.parse(url)
uri.scheme = "http" if uri.present?
uri.to_s
end
end
18 changes: 18 additions & 0 deletions app/graphql/types/person_software_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class PersonSoftwareConnectionWithMetaType < BaseConnection
edge_type(EventDataEdgeType, edge_class: EventDataEdge)
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true

def total_count
Event.query(nil, obj_id: https_to_http(object.parent.uid ? "https://orcid.org/#{object.parent.uid}" : nil || object.parent[:id]), citation_type: "Person-SoftwareSourceCode").results.total
end

def https_to_http(url)
uri = Addressable::URI.parse(url)
uri.scheme = "http" if uri.present?
uri.to_s
end
end

0 comments on commit 76a2288

Please sign in to comment.