From 31b5026da0f2d4abb97faf7e9865d4150bc8a71f Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 4 Dec 2019 18:42:31 +0000 Subject: [PATCH] correct totalcount when filtering by client_id or provider_id --- app/graphql/lupo_schema.rb | 2 +- app/graphql/types/client_type.rb | 8 ++++---- .../creative_work_connection_with_meta_type.rb | 2 +- app/graphql/types/data_catalog_type.rb | 18 +++++++++++++++--- .../types/dataset_connection_with_meta_type.rb | 2 +- app/graphql/types/dataset_type.rb | 6 +++--- app/graphql/types/funder_type.rb | 4 ++-- app/graphql/types/person_type.rb | 6 +++--- app/graphql/types/provider_type.rb | 4 ++-- .../publication_connection_with_meta_type.rb | 2 +- app/graphql/types/publication_type.rb | 4 ++-- app/graphql/types/query_type.rb | 18 +++++++++--------- .../software_connection_with_meta_type.rb | 2 +- app/graphql/types/software_type.rb | 4 ++-- app/graphql/types/usage_report_type.rb | 2 +- 15 files changed, 48 insertions(+), 36 deletions(-) diff --git a/app/graphql/lupo_schema.rb b/app/graphql/lupo_schema.rb index 6c0e62ebb..1978a88f3 100644 --- a/app/graphql/lupo_schema.rb +++ b/app/graphql/lupo_schema.rb @@ -5,7 +5,7 @@ class LupoSchema < GraphQL::Schema use ApolloFederation::Tracing - default_max_page_size 250 + default_max_page_size 1000 max_depth 10 # mutation(Types::MutationType) diff --git a/app/graphql/types/client_type.rb b/app/graphql/types/client_type.rb index 080bbf242..6e89238d6 100644 --- a/app/graphql/types/client_type.rb +++ b/app/graphql/types/client_type.rb @@ -10,23 +10,23 @@ class ClientType < BaseObject field :url, String, null: true, description: "The homepage of the client" field :system_email, String, null: true, description: "Client system email" field :software, String, null: true, description: "The name of the software that is used to run the repository" - field :prefixes, PrefixConnectionWithMetaType, null: false, description: "Prefixes managed by the client", connection: true, max_page_size: 100 do + field :prefixes, PrefixConnectionWithMetaType, null: false, description: "Prefixes managed by the client", connection: true, max_page_size: 1000 do argument :query, String, required: false argument :year, String, required: false argument :first, Int, required: false, default_value: 25 end - field :datasets, ClientDatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Datasets managed by the client" do + field :datasets, ClientDatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Datasets managed by the client" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :publications, ClientPublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Publications managed by the client" do + field :publications, ClientPublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Publications managed by the client" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, ClientSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software managed by the client" do + field :software_source_codes, ClientSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Software managed by the client" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/creative_work_connection_with_meta_type.rb b/app/graphql/types/creative_work_connection_with_meta_type.rb index 82c92d6d7..f1236d66a 100644 --- a/app/graphql/types/creative_work_connection_with_meta_type.rb +++ b/app/graphql/types/creative_work_connection_with_meta_type.rb @@ -9,6 +9,6 @@ class CreativeWorkConnectionWithMetaType < BaseConnection def total_count args = object.arguments - Doi.query(args[:query], state: "findable", page: { number: 1, size: args[:first] }).results.total + Doi.query(args[:query], client_id: args[:client_id], provider_id: args[:provider_id], state: "findable", page: { number: 1, size: args[:first] }).results.total end end diff --git a/app/graphql/types/data_catalog_type.rb b/app/graphql/types/data_catalog_type.rb index 430d47dcd..89e2ed611 100644 --- a/app/graphql/types/data_catalog_type.rb +++ b/app/graphql/types/data_catalog_type.rb @@ -23,17 +23,17 @@ class DataCatalogType < BaseObject # field :pid_systems, [String], null: true, description: "PID Systems" # field :apis, [ApiType], null: true, description: "APIs" field :software_application, [SoftwareApplicationType], null: true, description: "Software" - field :datasets, DataCatalogDatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Datasets hosted by the repository" do + field :datasets, DataCatalogDatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Datasets hosted by the repository" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :publications, DataCatalogPublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Publications hosted by the repository" do + field :publications, DataCatalogPublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Publications hosted by the repository" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, DataCatalogSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100, description: "Software hosted by the repository" do + field :software_source_codes, DataCatalogSoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 1000, description: "Software hosted by the repository" do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end @@ -88,4 +88,16 @@ def publications(**args) def software_source_codes(**args) Doi.query(args[:query], re3data_id: doi_from_url(object[:id]), resource_type_id: "Software", page: { number: 1, size: args[:first] }).results.to_a end + + def datasets(**args) + Doi.query(args[:query], client_id: object.uid, resource_type_id: "Dataset", page: { number: 1, size: args[:first] }).results.to_a + end + + def publications(**args) + Doi.query(args[:query], client_id: object.uid, resource_type_id: "Text", page: { number: 1, size: args[:first] }).results.to_a + end + + def software_source_codes(**args) + Doi.query(args[:query], client_id: object.uid, resource_type_id: "Software", page: { number: 1, size: args[:first] }).results.to_a + end end diff --git a/app/graphql/types/dataset_connection_with_meta_type.rb b/app/graphql/types/dataset_connection_with_meta_type.rb index b022f65be..68f79737c 100644 --- a/app/graphql/types/dataset_connection_with_meta_type.rb +++ b/app/graphql/types/dataset_connection_with_meta_type.rb @@ -15,7 +15,7 @@ class DatasetConnectionWithMetaType < BaseConnection def total_count args = object.arguments - Doi.query(args[:query], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.total + Doi.query(args[:query], client_id: args[:clent_id], provider_id: args[:provider_id], resource_type_id: "Dataset", state: "findable", page: { number: 1, size: args[:first] }).results.total end def dataset_connection_count diff --git a/app/graphql/types/dataset_type.rb b/app/graphql/types/dataset_type.rb index 24d08dcd3..68e3c061b 100644 --- a/app/graphql/types/dataset_type.rb +++ b/app/graphql/types/dataset_type.rb @@ -4,17 +4,17 @@ class DatasetType < BaseObject implements DoiItem implements MetricInterface - field :usage_reports, DatasetUsageReportConnectionWithMetaType, null: false, description: "Usage reports for this dataset", connection: true, max_page_size: 100 do + field :usage_reports, DatasetUsageReportConnectionWithMetaType, null: false, description: "Usage reports for this dataset", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end - field :datasets, DatasetDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 100 do + field :datasets, DatasetDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end field :publications, DatasetPublicationConnectionWithMetaType, null: false, description: "Referenced publications", connection: true do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, DatasetSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do + field :software_source_codes, DatasetSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/funder_type.rb b/app/graphql/types/funder_type.rb index d0b0335e4..bcc9bf302 100644 --- a/app/graphql/types/funder_type.rb +++ b/app/graphql/types/funder_type.rb @@ -8,7 +8,7 @@ class FunderType < BaseObject field :name, String, null: false, description: "The name of the funder." field :alternate_name, [String], null: true, description: "An alias for the funder." field :address, AddressType, null: true, description: "Physical address of the funder." - field :datasets, FunderDatasetConnectionWithMetaType, null: false, description: "Funded datasets", connection: true, max_page_size: 100 do + field :datasets, FunderDatasetConnectionWithMetaType, null: false, description: "Funded datasets", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end @@ -17,7 +17,7 @@ class FunderType < BaseObject argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, FunderSoftwareConnectionWithMetaType, null: false, description: "Funded software", connection: true, max_page_size: 100 do + field :software_source_codes, FunderSoftwareConnectionWithMetaType, null: false, description: "Funded software", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/person_type.rb b/app/graphql/types/person_type.rb index 6315c193f..4166c0efa 100644 --- a/app/graphql/types/person_type.rb +++ b/app/graphql/types/person_type.rb @@ -9,15 +9,15 @@ class PersonType < BaseObject field :given_name, String, null: true, hash_key: "given_names", description: "Given name. In the U.S., the first name of a Person." field :family_name, String, null: true, description: "Family name. In the U.S., the last name of an Person." - field :datasets, PersonDatasetConnectionWithMetaType, null: true, description: "Authored datasets", connection: true, max_page_size: 100 do + field :datasets, PersonDatasetConnectionWithMetaType, null: true, description: "Authored datasets", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end - field :publications, PersonPublicationConnectionWithMetaType, null: true, description: "Authored publications", connection: true, max_page_size: 100 do + field :publications, PersonPublicationConnectionWithMetaType, null: true, description: "Authored publications", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, PersonSoftwareConnectionWithMetaType, null: true, description: "Authored software", connection: true, max_page_size: 100 do + field :software_source_codes, PersonSoftwareConnectionWithMetaType, null: true, description: "Authored software", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/provider_type.rb b/app/graphql/types/provider_type.rb index 67bed365e..15d8aa271 100644 --- a/app/graphql/types/provider_type.rb +++ b/app/graphql/types/provider_type.rb @@ -15,14 +15,14 @@ class ProviderType < BaseObject field :organization_type, String, null: true, description: "Type of organization" field :focus_area, String, null: true, description: "Field of science covered by provider" field :joined, String, null: true, description: "Date provider joined DataCite" - field :prefixes, PrefixConnectionWithMetaType, null: false, description: "Prefixes managed by the provider", connection: true, max_page_size: 100 do + field :prefixes, PrefixConnectionWithMetaType, null: false, description: "Prefixes managed by the provider", connection: true, max_page_size: 1000 do argument :query, String, required: false argument :state, String, required: false argument :year, String, required: false argument :first, Int, required: false, default_value: 25 end - field :clients, ClientConnectionWithMetaType, null: false, description: "Clients associated with the provider", connection: true, max_page_size: 100 do + field :clients, ClientConnectionWithMetaType, null: false, description: "Clients associated with the provider", connection: true, max_page_size: 1000 do argument :query, String, required: false argument :year, String, required: false argument :software, String, required: false diff --git a/app/graphql/types/publication_connection_with_meta_type.rb b/app/graphql/types/publication_connection_with_meta_type.rb index 6632d8f00..732d5983e 100644 --- a/app/graphql/types/publication_connection_with_meta_type.rb +++ b/app/graphql/types/publication_connection_with_meta_type.rb @@ -15,7 +15,7 @@ class PublicationConnectionWithMetaType < BaseConnection def total_count args = object.arguments - Doi.query(args[:query], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.total + Doi.query(args[:query], client_id: args[:client_id], provider_id: args[:provider_id], resource_type_id: "Text", state: "findable", page: { number: 1, size: args[:first] }).results.total end def publication_connection_count diff --git a/app/graphql/types/publication_type.rb b/app/graphql/types/publication_type.rb index b2a0ee9ef..41c294cea 100644 --- a/app/graphql/types/publication_type.rb +++ b/app/graphql/types/publication_type.rb @@ -4,14 +4,14 @@ class PublicationType < BaseObject implements DoiItem implements MetricInterface - field :datasets, PublicationDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 100 do + field :datasets, PublicationDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end field :publications, PublicationPublicationConnectionWithMetaType, null: false, description: "Referenced publications", connection: true do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, PublicationSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do + field :software_source_codes, PublicationSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 5e5c0e50f..26f17227b 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -3,7 +3,7 @@ class QueryType < BaseObject extend_type - field :providers, ProviderConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :providers, ProviderConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end @@ -20,7 +20,7 @@ def provider(id:) ElasticsearchLoader.for(Provider).load(id) end - field :clients, ClientConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :clients, ClientConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :year, String, required: false argument :software, String, required: false @@ -63,7 +63,7 @@ def prefix(id:) Prefix.where(prefix: id).first end - field :funders, FunderConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :funders, FunderConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end @@ -103,7 +103,7 @@ def data_catalogs(query: nil, first: nil) DataCatalog.query(query, limit: first).fetch(:data, []) end - field :organizations, OrganizationConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :organizations, OrganizationConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end @@ -143,7 +143,7 @@ def people(query: nil, first: nil) Person.query(query, limit: first).fetch(:data, []) end - field :creative_works, CreativeWorkConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :creative_works, CreativeWorkConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :ids, String, required: false argument :client_id, String, required: false @@ -168,7 +168,7 @@ def creative_work(id:) set_doi(id) end - field :datasets, DatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :datasets, DatasetConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false @@ -187,7 +187,7 @@ def dataset(id:) set_doi(id) end - field :publications, PublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :publications, PublicationConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false @@ -359,7 +359,7 @@ def service(id:) set_doi(id) end - field :software_source_codes, SoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :software_source_codes, SoftwareConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :query, String, required: false argument :client_id, String, required: false argument :provider_id, String, required: false @@ -429,7 +429,7 @@ def other(id:) set_doi(id) end - field :usage_reports, UsageReportConnectionWithMetaType, null: false, connection: true, max_page_size: 100 do + field :usage_reports, UsageReportConnectionWithMetaType, null: false, connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/software_connection_with_meta_type.rb b/app/graphql/types/software_connection_with_meta_type.rb index 5f48b694b..b314553e8 100644 --- a/app/graphql/types/software_connection_with_meta_type.rb +++ b/app/graphql/types/software_connection_with_meta_type.rb @@ -15,7 +15,7 @@ class SoftwareConnectionWithMetaType < BaseConnection def total_count args = object.arguments - Doi.query(args[:query], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.total + Doi.query(args[:query], client_id: args[:client_id], provider_id: args[:provider_id], resource_type_id: "Software", state: "findable", page: { number: 1, size: args[:first] }).results.total end def software_connection_count diff --git a/app/graphql/types/software_type.rb b/app/graphql/types/software_type.rb index fea476415..19dab5ab2 100644 --- a/app/graphql/types/software_type.rb +++ b/app/graphql/types/software_type.rb @@ -4,14 +4,14 @@ class SoftwareType < BaseObject implements DoiItem implements MetricInterface - field :datasets, SoftwareDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 100 do + field :datasets, SoftwareDatasetConnectionWithMetaType, null: false, description: "Referenced datasets", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end field :publications, SoftwarePublicationConnectionWithMetaType, null: false, description: "Referenced publications", connection: true do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :software_source_codes, SoftwareSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, max_page_size: 100 do + field :software_source_codes, SoftwareSoftwareConnectionWithMetaType, null: false, description: "Referenced software", connection: true, 0 do argument :first, Int, required: false, default_value: 25 end diff --git a/app/graphql/types/usage_report_type.rb b/app/graphql/types/usage_report_type.rb index c4def59cb..c1c782843 100644 --- a/app/graphql/types/usage_report_type.rb +++ b/app/graphql/types/usage_report_type.rb @@ -7,7 +7,7 @@ class UsageReportType < BaseObject field :client_id, String, null: true, description: "Client who created the report" field :reporting_period, ReportingPeriodType, null: false, description: "Time period covered by the report" field :date_created, String, null: false, description: "Date information was created" - field :datasets, UsageReportDatasetConnectionWithMetaType, null: false, description: "Datasets included in usage report", connection: true, max_page_size: 100 do + field :datasets, UsageReportDatasetConnectionWithMetaType, null: false, description: "Datasets included in usage report", connection: true, max_page_size: 1000 do argument :first, Int, required: false, default_value: 25 end