From 9e71a926e95c52bc756d55372e57dea325c2ed9d Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sun, 21 Jul 2019 15:59:55 +0200 Subject: [PATCH] totalConnectionCounts for organization in graphql --- app/graphql/types/dataset_connection_with_meta_type.rb | 5 +++++ app/graphql/types/publication_connection_with_meta_type.rb | 5 +++++ app/graphql/types/software_connection_with_meta_type.rb | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/app/graphql/types/dataset_connection_with_meta_type.rb b/app/graphql/types/dataset_connection_with_meta_type.rb index 3ff3812b4..49bfa1995 100644 --- a/app/graphql/types/dataset_connection_with_meta_type.rb +++ b/app/graphql/types/dataset_connection_with_meta_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/publication_connection_with_meta_type.rb b/app/graphql/types/publication_connection_with_meta_type.rb index 0abae12c1..b999963eb 100644 --- a/app/graphql/types/publication_connection_with_meta_type.rb +++ b/app/graphql/types/publication_connection_with_meta_type.rb @@ -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 @@ -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 diff --git a/app/graphql/types/software_connection_with_meta_type.rb b/app/graphql/types/software_connection_with_meta_type.rb index 07c545fdb..b7625e51f 100644 --- a/app/graphql/types/software_connection_with_meta_type.rb +++ b/app/graphql/types/software_connection_with_meta_type.rb @@ -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 @@ -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