From b2d3da5057c938e8f8d5a7dd4ff0694e3223666f Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Sat, 20 Jul 2019 08:41:05 +0200 Subject: [PATCH] calculate total number of pages. #310 --- app/controllers/dois_controller.rb | 2 +- app/controllers/events_controller.rb | 2 +- app/graphql/types/organization_type.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index c973ac808..226180f24 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -104,7 +104,7 @@ def index else results = response.results total = response.results.total - total_for_pages = page[:cursor].present? ? total.to_f : [total.to_f, 10000].min + total_for_pages = page[:cursor].nil? ? [total.to_f, 10000].min : total.to_f total_pages = page[:size] > 0 ? (total_for_pages / page[:size]).ceil : 0 end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index f237fa293..49f3a3586 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -110,7 +110,7 @@ def index end total = response.results.total - total_for_pages = page[:cursor].nil? ? total.to_f : [total.to_f, 10000].min + total_for_pages = page[:cursor].nil? ? [total.to_f, 10000].min : total.to_f total_pages = page[:size] > 0 ? (total_for_pages / page[:size]).ceil : 0 sources = total.positive? ? facet_by_source(response.response.aggregations.sources.buckets) : nil diff --git a/app/graphql/types/organization_type.rb b/app/graphql/types/organization_type.rb index fdc953fa3..d1d5f9a76 100644 --- a/app/graphql/types/organization_type.rb +++ b/app/graphql/types/organization_type.rb @@ -16,16 +16,16 @@ class OrganizationType < BaseObject field :wikidata, [String], null: true, description: "Wikidata identifiers for organization" field :grid, [String], null: true, description: "GRID identifiers for organization" - field :datasets, OrganizationDatasetConnectionWithMetaType, null: false, description: "Funded datasets", connection: true, max_page_size: 100 do + field :datasets, OrganizationDatasetConnectionWithMetaType, null: false, description: "Datasets from this organization", connection: true, max_page_size: 100 do argument :first, Int, required: false, default_value: 25 end - field :publications, OrganizationPublicationConnectionWithMetaType, null: false, description: "Funded publications", connection: true do + field :publications, OrganizationPublicationConnectionWithMetaType, null: false, description: "Publications from this organization", connection: true do argument :query, String, required: false argument :first, Int, required: false, default_value: 25 end - field :softwares, OrganizationSoftwareConnectionWithMetaType, null: false, description: "Funded software", connection: true, max_page_size: 100 do + field :softwares, OrganizationSoftwareConnectionWithMetaType, null: false, description: "Software from this organization", connection: true, max_page_size: 100 do argument :first, Int, required: false, default_value: 25 end