Skip to content

Commit

Permalink
Don't introduce Kaminari -- will_paginate is in maintenance mode, but…
Browse files Browse the repository at this point in the history
… elastic-search rails still uses it internally so stick with it for now.

Change a couple uses of 'paginate()' on ES-backed models to 'page()' from the elasticsearch-rails interface.
  • Loading branch information
machinehum committed Oct 30, 2023
1 parent 72d75e5 commit a1c938f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ gem 'haml'
gem 'nokogiri'
gem 'simple_form'
gem 'breadcrumbs_on_rails'
gem 'kaminari'
gem 'mail_form'
gem 'will_paginate'
gem 'will_paginate-bootstrap4'
Expand Down
13 changes: 0 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,6 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.3)
kaminari (1.2.2)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.2)
kaminari-activerecord (= 1.2.2)
kaminari-core (= 1.2.2)
kaminari-actionview (1.2.2)
actionview
kaminari-core (= 1.2.2)
kaminari-activerecord (1.2.2)
activerecord
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -407,7 +395,6 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails (= 4.3.5)
json
kaminari
listen
mail_form
net-ldap
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/admin/trials_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def recent_as

def index
if params[:q].blank?
@trials = Trial.includes(:trial_interventions, :conditions).paginate(page: params[:page]).where(visible: true)
@trials = Trial.includes(:trial_interventions, :conditions).page(page_param).where(visible: true)
if SystemInfo.trial_approval
@trials = @trials.where(approved: true)
end
else
@trials = Trial.includes(:trial_interventions, :conditions).match_all_admin({ q: params[:q].downcase }).page(params[:page]).records
@trials = Trial.includes(:trial_interventions, :conditions).match_all_admin({ q: params[:q].downcase }).page(page_param).records
end

add_breadcrumb 'Trials Administration'
Expand Down Expand Up @@ -114,9 +114,9 @@ def update

def all_under_review
if params[:q].blank?
@trials = Trial.includes(:trial_locations).paginate(page: params[:page]).where(approved: false).where(visible: true).order(created_at: :desc)
@trials = Trial.includes(:trial_locations).page(page_param).where(approved: false).where(visible: true).order(created_at: :desc)
else
@trials = Trial.includes(:trial_locations).match_all_under_review_admin({ q: params[:q].downcase }).page(params[:page]).records
@trials = Trial.includes(:trial_locations).match_all_under_review_admin({ q: params[:q].downcase }).page(page_param).records
end

add_breadcrumb 'Trials Administration', :admin_trials_path
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def authorize_researcher
end
helper_method :authorize_researcher

def page_param
params[:page].to_i > 0 ? params[:page].to_i : 1
end

private
def system
@system_info = SystemInfo.current
Expand Down

0 comments on commit a1c938f

Please sign in to comment.