Skip to content

Commit

Permalink
show connection counts within one type. #299
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 30, 2019
1 parent 37f10cb commit 026d8de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/graphql/types/dataset_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class DatasetConnectionWithMetaType < BaseConnection
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :dataset_connection_count, Integer, null: false, cache: true
field :publication_connection_count, Integer, null: false, cache: true
field :software_connection_count, Integer, null: false, cache: true
field :researcher_connection_count, Integer, null: false, cache: true
Expand All @@ -16,6 +17,10 @@ def total_count
Doi.query(args[:query], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.total
end

def dataset_connection_count
Event.query(nil, citation_type: "Dataset-Dataset").results.total
end

def publication_connection_count
Event.query(nil, citation_type: "Dataset-ScholarlyArticle").results.total
end
Expand Down
5 changes: 5 additions & 0 deletions app/graphql/types/publication_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class PublicationConnectionWithMetaType < BaseConnection
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
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 :researcher_connection_count, Integer, null: false, cache: true
Expand All @@ -16,6 +17,10 @@ def total_count
Doi.query(args[:query], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.total
end

def publication_connection_count
Event.query(nil, citation_type: "ScholarlyArticle-ScholarlyArticle").results.total
end

def dataset_connection_count
Event.query(nil, citation_type: "Dataset-ScholarlyArticle").results.total
end
Expand Down
5 changes: 5 additions & 0 deletions app/graphql/types/software_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SoftwareConnectionWithMetaType < BaseConnection
field_class GraphQL::Cache::Field

field :total_count, Integer, null: false, cache: true
field :software_connection_count, Integer, null: false, cache: true
field :publication_connection_count, Integer, null: false, cache: true
field :dataset_connection_count, Integer, null: false, cache: true
field :researcher_connection_count, Integer, null: false, cache: true
Expand All @@ -16,6 +17,10 @@ def total_count
Doi.query(args[:query], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.total
end

def software_connection_count
Event.query(nil, citation_type: "SoftwareSourceCode-SoftwareSourceCode").results.total
end

def publication_connection_count
Event.query(nil, citation_type: "ScholarlyArticle-SoftwareSourceCode").results.total
end
Expand Down

0 comments on commit 026d8de

Please sign in to comment.