From da5cef26db812ec213a39aecdda6a67a071aeef6 Mon Sep 17 00:00:00 2001 From: piyush828-design Date: Wed, 16 Apr 2025 16:02:06 +0530 Subject: [PATCH] upgraded pagy to latest version --- Gemfile | 3 +-- Gemfile.lock | 5 ++--- app/controllers/api/v1/customers_controller.rb | 2 +- config/initializers/pagy.rb | 12 ++++++------ spec/requests/api/v1/customers_spec.rb | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index 291d8087b6..3eb9efa049 100644 --- a/Gemfile +++ b/Gemfile @@ -63,10 +63,9 @@ gem 'devise-token_authenticatable' gem 'jwt', '~> 2.3' gem 'oauth2', '~> 1.4.7' # Used for Stripe Connect -gem 'activesupport' gem 'datafoodconsortium-connector' gem 'jsonapi-serializer' -gem 'pagy', '~> 8' +gem 'pagy', '~> 9' gem 'rswag-api' gem 'rswag-ui' diff --git a/Gemfile.lock b/Gemfile.lock index 93cf01fc12..01f026fc9c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -495,7 +495,7 @@ GEM validate_url webfinger (~> 2.0) orm_adapter (0.5.0) - pagy (8.6.3) + pagy (9.3.4) paper_trail (15.1.0) activerecord (>= 6.1) request_store (~> 1.4) @@ -869,7 +869,6 @@ DEPENDENCIES activerecord-import activerecord-postgresql-adapter activerecord-session_store - activesupport acts-as-taggable-on acts_as_list (= 1.0.4) angular-rails-templates (>= 0.3.0) @@ -940,7 +939,7 @@ DEPENDENCIES omniauth_openid_connect openid_connect order_management! - pagy (~> 8) + pagy (~> 9) paper_trail paranoia (~> 2.4) paypal-sdk-merchant (= 1.117.2) diff --git a/app/controllers/api/v1/customers_controller.rb b/app/controllers/api/v1/customers_controller.rb index 0fe756efc5..5353c6d39f 100644 --- a/app/controllers/api/v1/customers_controller.rb +++ b/app/controllers/api/v1/customers_controller.rb @@ -18,7 +18,7 @@ module Api end def index - @pagy, customers = pagy(search_customers, pagy_options) + @pagy, customers = pagy(search_customers, **pagy_options) render json: Api::V1::CustomerSerializer.new(customers, pagination_options) end diff --git a/config/initializers/pagy.rb b/config/initializers/pagy.rb index eab7d3a437..2aacb32007 100644 --- a/config/initializers/pagy.rb +++ b/config/initializers/pagy.rb @@ -2,18 +2,18 @@ require 'pagy/extras/arel' require 'pagy/extras/array' -require 'pagy/extras/items' +require 'pagy/extras/limit' require 'pagy/extras/overflow' # Pagy Variables # See https://ddnexus.github.io/pagy/api/pagy#variables -Pagy::DEFAULT[:items] = 100 +Pagy::DEFAULT[:limit] = 100 -# Items extra: Allow the client to request a custom number of items per page with an optional +# limit extra: Allow the client to request a custom number of limit per page with an optional # selector UI -# See https://ddnexus.github.io/pagy/extras/items -Pagy::DEFAULT[:items_param] = :per_page -Pagy::DEFAULT[:max_items] = 100 +# See https://ddnexus.github.io/pagy/extras/limit +Pagy::DEFAULT[:limit_param] = :per_page +Pagy::DEFAULT[:limit_max] = 100 # For handling requests for non-existant pages eg: page 35 when there are only 4 pages of results Pagy::DEFAULT[:overflow] = :empty_page diff --git a/spec/requests/api/v1/customers_spec.rb b/spec/requests/api/v1/customers_spec.rb index 9af5ad71d1..bc9e8308cc 100644 --- a/spec/requests/api/v1/customers_spec.rb +++ b/spec/requests/api/v1/customers_spec.rb @@ -133,7 +133,7 @@ RSpec.describe "Customers", type: :request, swagger_doc: "v1.yaml", feature: :ap it "informs about invalid pages" do get "/api/v1/customers", params: { page: "0" } expect(json_response_ids).to eq nil - expect(json_error_detail).to eq 'expected :page >= 1; got "0"' + expect(json_error_detail).to eq "expected :page >= 1; got 0" end end