Skip to content

Commit

Permalink
calculate total number of pages. #310
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 20, 2019
1 parent e9f5e33 commit b2d3da5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Expand Down

0 comments on commit b2d3da5

Please sign in to comment.