Skip to content

Commit

Permalink
correct totalcount when filtering by client_id or provider_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 4, 2019
1 parent 3bdfdd4 commit 31b5026
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/graphql/lupo_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions app/graphql/types/client_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 15 additions & 3 deletions app/graphql/types/data_catalog_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/graphql/types/dataset_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/graphql/types/dataset_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/funder_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down
6 changes: 3 additions & 3 deletions app/graphql/types/person_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/provider_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/publication_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/publication_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/software_connection_with_meta_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/graphql/types/software_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/graphql/types/usage_report_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 31b5026

Please sign in to comment.