Skip to content

Commit

Permalink
fix cursor-based navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 1, 2019
1 parent d776ead commit 1c824a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
6 changes: 4 additions & 2 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ def index
subjects: subjects
}.compact

logger.info page.inspect

options[:links] = {
self: request.original_url,
next: results.size < page[:size] ? nil : request.base_url + "/dois?" + {
next: results.size < page[:size] || page[:size] == 0 ? nil : request.base_url + "/dois?" + {
query: params[:query],
"provider-id" => params[:provider_id],
"client-id" => params[:client_id],
"page[cursor]" => page[:cursor].present? ? Array.wrap(results.to_a.last.to_h[:sort]).first : nil,
"page[cursor]" => page[:cursor].present? ? Array.wrap(results.to_a.last[:sort]).first : nil,
"page[number]" => page[:cursor].blank? && page[:number].present? ? page[:number] + 1 : nil,
"page[size]" => page[:size] }.compact.to_query
}.compact
Expand Down
9 changes: 0 additions & 9 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ def index
page: page[:number]
}.compact

options[:links] = {
self: request.original_url,
next: @dois.blank? ? nil : request.base_url + "/dois?" + {
query: params[:query],
"member-id" => params[:provider_id],
"data-center-id" => params[:client_id],
"page[cursor]" => page[:cursor].present? ? Array.wrap(@dois.to_a.last.to_h[:sort]).first : nil,
"page[size]" => page[:size] }.compact.to_query
}.compact
options[:include] = @include
options[:is_collection] = true
options[:links] = nil
Expand Down

0 comments on commit 1c824a4

Please sign in to comment.