From a1c938f76ecb85281cb66a6f7f2470a2b4921e8b Mon Sep 17 00:00:00 2001 From: Brian Hayden Date: Mon, 30 Oct 2023 12:40:06 -0500 Subject: [PATCH] Don't introduce Kaminari -- will_paginate is in maintenance mode, but 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. --- Gemfile | 1 - Gemfile.lock | 13 ------------- app/controllers/admin/trials_controller.rb | 8 ++++---- app/controllers/application_controller.rb | 4 ++++ 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 9e44510..27008d7 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 3423fd2..6909341 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -407,7 +395,6 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails (= 4.3.5) json - kaminari listen mail_form net-ldap diff --git a/app/controllers/admin/trials_controller.rb b/app/controllers/admin/trials_controller.rb index 55c485e..c364962 100644 --- a/app/controllers/admin/trials_controller.rb +++ b/app/controllers/admin/trials_controller.rb @@ -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' @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 45ccd75..3649359 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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