From 9b16e5ec1965ba243e856958e89e19f8c77c4631 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Mon, 22 Jul 2019 09:24:02 +0200 Subject: [PATCH] show organization-researcher kpis in graphql --- .../types/organization_connection_with_meta_type.rb | 5 +++++ app/graphql/types/researcher_connection_with_meta_type.rb | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/graphql/types/organization_connection_with_meta_type.rb b/app/graphql/types/organization_connection_with_meta_type.rb index 0abbc4323..750264043 100644 --- a/app/graphql/types/organization_connection_with_meta_type.rb +++ b/app/graphql/types/organization_connection_with_meta_type.rb @@ -5,10 +5,15 @@ class OrganizationConnectionWithMetaType < BaseConnection field_class GraphQL::Cache::Field field :total_count, Integer, null: false, cache: true + field :researcher_connection_count, Integer, null: false, cache: true def total_count args = object.arguments Organization.query(args[:query], limit: 0).dig(:meta, "total").to_i end + + def researcher_connection_count + Event.query(nil, citation_type: "Organization-Person").results.total + end end diff --git a/app/graphql/types/researcher_connection_with_meta_type.rb b/app/graphql/types/researcher_connection_with_meta_type.rb index 295e5b7ff..61db6e6a6 100644 --- a/app/graphql/types/researcher_connection_with_meta_type.rb +++ b/app/graphql/types/researcher_connection_with_meta_type.rb @@ -8,7 +8,8 @@ class ResearcherConnectionWithMetaType < BaseConnection 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 total_count args = object.arguments @@ -26,4 +27,8 @@ def dataset_connection_count 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