From 217e64a6ba5a94ffe78305116c24fb7a83405ce9 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 11 Apr 2020 08:34:47 +0200 Subject: [PATCH] fix query parameters for graphql connections --- app/graphql/types/data_catalog_type.rb | 2 +- app/graphql/types/doi_item.rb | 2 +- app/graphql/types/funder_type.rb | 2 +- app/graphql/types/member_type.rb | 2 +- app/graphql/types/organization_type.rb | 2 +- app/graphql/types/person_type.rb | 2 +- app/graphql/types/query_type.rb | 2 +- app/graphql/types/repository_type.rb | 8 ++++---- app/graphql/types/software_connection_type.rb | 4 ++-- app/graphql/types/sound_connection_type.rb | 4 ++-- app/graphql/types/work_connection_type.rb | 2 +- app/graphql/types/workflow_connection_type.rb | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/graphql/types/data_catalog_type.rb b/app/graphql/types/data_catalog_type.rb index 1e74c6df2..b552be727 100644 --- a/app/graphql/types/data_catalog_type.rb +++ b/app/graphql/types/data_catalog_type.rb @@ -76,7 +76,7 @@ def software_application end def datasets(**args) - Doi.query(args[:query], re3data_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], member_id: args[:member_id], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.to_a + Doi.query(args[:query], re3data_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.to_a end def view_count diff --git a/app/graphql/types/doi_item.rb b/app/graphql/types/doi_item.rb index e67be1e80..b56e38efc 100644 --- a/app/graphql/types/doi_item.rb +++ b/app/graphql/types/doi_item.rb @@ -266,7 +266,7 @@ def version_of(**args) def response(**args) return [] if args[:ids].blank? - Doi.query(args[:query], ids: args[:ids], funder_id: args[:funder_id], user_id: args[:user_id], repository_id: args[:repository_id], member_id: args[:member_id], affiliation_id: args[:affiliation_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + Doi.query(args[:query], ids: args[:ids], funder_id: args[:funder_id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a end def doi_link(url) diff --git a/app/graphql/types/funder_type.rb b/app/graphql/types/funder_type.rb index 6ce597861..026225a5b 100644 --- a/app/graphql/types/funder_type.rb +++ b/app/graphql/types/funder_type.rb @@ -129,6 +129,6 @@ def citation_count end def response(**args) - Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], repository_id: args[:repository_id], member_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) + Doi.query(args[:query], funder_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/member_type.rb b/app/graphql/types/member_type.rb index e6e9d5b00..d3d65c2c2 100644 --- a/app/graphql/types/member_type.rb +++ b/app/graphql/types/member_type.rb @@ -176,6 +176,6 @@ def citation_count end def response(**args) - Doi.query(args[:query], user_id: args[:user_id], repository_id: args[:repository_id], provider_id: object.uid, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) + Doi.query(args[:query], user_id: args[:user_id], client_id: args[:repository_id], provider_id: object.uid, funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/organization_type.rb b/app/graphql/types/organization_type.rb index 05d7849b0..6838a60a7 100644 --- a/app/graphql/types/organization_type.rb +++ b/app/graphql/types/organization_type.rb @@ -137,6 +137,6 @@ def citation_count end def response(**args) - Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], repository_id: args[:repository_id], member_id: args[:member_id], funder_id: args[:funder_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) + Doi.query(args[:query], affiliation_id: object[:id], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], funder_id: args[:funder_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/person_type.rb b/app/graphql/types/person_type.rb index e9e7f016f..fafe91bd4 100644 --- a/app/graphql/types/person_type.rb +++ b/app/graphql/types/person_type.rb @@ -121,6 +121,6 @@ def citation_count end def response(**args) - Doi.query(args[:query], user_id: object[:id], repository_id: args[:repository_id], member_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) + Doi.query(args[:query], user_id: object[:id], client_id: args[:repository_id], provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_funder: args[:has_funder], has_affiliation: args[:has_affiliation], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 3c702eedc..6930ccf2b 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -681,7 +681,7 @@ def usage_report(id:) end def response(**args) - @response ||= Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], repository_id: args[:repository_id], member_id: args[:member_id], resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a + @response ||= Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], provider_id: args[:member_id], resource_type_id: args[:resource_type_id], resource_type: args[:resource_type], has_person: args[:has_person], has_funder: args[:has_funder], has_organization: args[:has_organization], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }).results.to_a end def set_doi(id) diff --git a/app/graphql/types/repository_type.rb b/app/graphql/types/repository_type.rb index ef626b973..7662dd3f0 100644 --- a/app/graphql/types/repository_type.rb +++ b/app/graphql/types/repository_type.rb @@ -142,22 +142,22 @@ def prefixes(**args) def view_count args = { first: 0 } r = response(args) - r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : [] + r.results.total.positive? ? aggregate_count(r.response.aggregations.views.buckets) : 0 end def download_count args = { first: 0 } r = response(args) - r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : [] + r.results.total.positive? ? aggregate_count(r.response.aggregations.downloads.buckets) : 0 end def citation_count args = { first: 0 } r = response(args) - r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : [] + r.results.total.positive? ? aggregate_count(r.response.aggregations.citations.buckets) : 0 end def response(**args) - Doi.query(args[:query], funder_id: args[:funder_id], user_id: args[:user_id], repository_id: object.uid, member_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) + Doi.query(args[:query], funder_id: args[:funder_id], user_id: args[:user_id], client_id: object.uid, provider_id: args[:member_id], affiliation_id: args[:affiliation_id], resource_type_id: args[:resource_type_id], has_person: args[:has_person], has_organization: args[:has_organization], has_funder: args[:has_funder], has_citations: args[:has_citations], has_parts: args[:has_parts], has_versions: args[:has_versions], has_views: args[:has_views], has_downloads: args[:has_downloads], state: "findable", page: { number: 1, size: args[:first] }) end end diff --git a/app/graphql/types/software_connection_type.rb b/app/graphql/types/software_connection_type.rb index 36e0c72c3..9b1acb21e 100644 --- a/app/graphql/types/software_connection_type.rb +++ b/app/graphql/types/software_connection_type.rb @@ -31,8 +31,8 @@ def response(**args) Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], - repository_id: args[:repository_id], - member_id: args[:member_id], + client_id: args[:repository_id], + provider_id: args[:member_id], funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], re3data_id: args[:re3data_id], diff --git a/app/graphql/types/sound_connection_type.rb b/app/graphql/types/sound_connection_type.rb index 629802c40..043bb33c9 100644 --- a/app/graphql/types/sound_connection_type.rb +++ b/app/graphql/types/sound_connection_type.rb @@ -24,8 +24,8 @@ def response(**args) Doi.query(args[:query], ids: args[:ids], user_id: args[:user_id], - repository_id: args[:repository_id], - member_id: args[:member_id], + client_id: args[:repository_id], + provider_id: args[:member_id], funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], re3data_id: args[:re3data_id], diff --git a/app/graphql/types/work_connection_type.rb b/app/graphql/types/work_connection_type.rb index e78109f90..c1fcba0f5 100644 --- a/app/graphql/types/work_connection_type.rb +++ b/app/graphql/types/work_connection_type.rb @@ -33,7 +33,7 @@ def response(**args) ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], - member_id: args[:member_id], + provider_id: args[:member_id], funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], re3data_id: args[:re3data_id], diff --git a/app/graphql/types/workflow_connection_type.rb b/app/graphql/types/workflow_connection_type.rb index 8fede7f69..6e798386e 100644 --- a/app/graphql/types/workflow_connection_type.rb +++ b/app/graphql/types/workflow_connection_type.rb @@ -25,7 +25,7 @@ def response(**args) ids: args[:ids], user_id: args[:user_id], client_id: args[:repository_id], - member_id: args[:member_id], + provider_id: args[:member_id], funder_id: args[:funder_id], affiliation_id: args[:affiliation_id], re3data_id: args[:re3data_id],