Skip to content

Commit

Permalink
totalConnectionCounts for organization in graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 21, 2019
1 parent e34a6ad commit 9e71a92
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 @@ -10,6 +10,7 @@ class DatasetConnectionWithMetaType < BaseConnection
field :software_connection_count, Integer, null: false, cache: true
field :researcher_connection_count, Integer, null: false, cache: true
field :funder_connection_count, Integer, null: false, cache: true
field :organization_connection_count, Integer, null: false, cache: true

def total_count
args = object.arguments
Expand All @@ -36,4 +37,8 @@ def researcher_connection_count
def funder_connection_count
Event.query(nil, citation_type: "Dataset-Funder").results.total
end

def organization_connection_count
Event.query(nil, citation_type: "Dataset-Organization").results.total
end
end
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 @@ -10,6 +10,7 @@ class PublicationConnectionWithMetaType < BaseConnection
field :software_connection_count, Integer, null: false, cache: true
field :researcher_connection_count, Integer, null: false, cache: true
field :funder_connection_count, Integer, null: false, cache: true
field :organization_connection_count, Integer, null: false, cache: true

def total_count
args = object.arguments
Expand All @@ -36,4 +37,8 @@ def researcher_connection_count
def funder_connection_count
Event.query(nil, citation_type: "Funder-ScholarlyArticle").results.total
end

def organization_connection_count
Event.query(nil, citation_type: "Organization-ScholarlyArticle").results.total
end
end
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 @@ -10,6 +10,7 @@ class SoftwareConnectionWithMetaType < BaseConnection
field :dataset_connection_count, Integer, null: false, cache: true
field :researcher_connection_count, Integer, null: false, cache: true
field :funder_connection_count, Integer, null: false, cache: true
field :organization_connection_count, Integer, null: false, cache: true

def total_count
args = object.arguments
Expand All @@ -36,4 +37,8 @@ def researcher_connection_count
def funder_connection_count
Event.query(nil, citation_type: "Funder-SoftwareSourceCode").results.total
end

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

0 comments on commit 9e71a92

Please sign in to comment.