Skip to content

Commit

Permalink
show organization-researcher kpis in graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 22, 2019
1 parent 456da68 commit 9b16e5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/graphql/types/organization_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion app/graphql/types/researcher_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit 9b16e5e

Please sign in to comment.