Skip to content

Commit

Permalink
make sure page parameter is a hash. #181
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 9, 2019
1 parent f66f395 commit 7bab293
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/controllers/client_prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def index
end

# pagination
page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
page[:number] = page[:number] && page[:number].to_i > 0 ? page[:number].to_i : 1
page[:size] = page[:size] && (1..1000).include?(page[:size].to_i) ? page[:size].to_i : 25
total = collection.count
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def index
else { "name.raw" => { order: 'asc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = page[:size] > 0 ? 10000/page[:size] : 1
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/data_centers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def index
else { "name.raw" => { order: 'asc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = 1
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def index
else { updated: { order: 'desc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}

if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
collection = @doi.media
total = @doi.cached_media_count.reduce(0) { |sum, d| sum + d[:count].to_i }

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
page[:number] = page[:number] && page[:number].to_i > 0 ? page[:number].to_i : 1
page[:size] = page[:size] && (1..1000).include?(page[:size].to_i) ? page[:size].to_i : 25
total_pages = (total.to_f / page[:size]).ceil
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
else { "name.raw" => { order: 'asc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = 1
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/metadata_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
collection = @doi.metadata
total = @doi.cached_metadata_count.reduce(0) { |sum, d| sum + d[:count].to_i }

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
page[:number] = page[:number] && page[:number].to_i > 0 ? page[:number].to_i : 1
page[:size] = page[:size] && (1..1000).include?(page[:size].to_i) ? page[:size].to_i : 25
total_pages = (total.to_f / page[:size]).ceil
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def index
end

# pagination
page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
page[:number] = page[:number] && page[:number].to_i > 0 ? page[:number].to_i : 1
page[:size] = page[:size] && (1..1000).include?(page[:size].to_i) ? page[:size].to_i : 25
total = collection.count
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/provider_prefixes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def index
end

# pagination
page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
page[:number] = page[:number] && page[:number].to_i > 0 ? page[:number].to_i : 1
page[:size] = page[:size] && (1..1000).include?(page[:size].to_i) ? page[:size].to_i : 25
total = collection.count
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index
else { "name.raw" => { order: 'asc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = page[:size] > 0 ? 10000/page[:size] : 1
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
else { updated: { order: 'desc' }}
end

page = params[:page] || {}
page = params[:page].is_a?(Hash) ? params[:page] : {}
if page[:size].present?
page[:size] = [page[:size].to_i, 1000].min
max_number = page[:size] > 0 ? 10000/page[:size] : 1
Expand Down

0 comments on commit 7bab293

Please sign in to comment.