From f022d382eeadf8489b6548a8e9cd2413bf234d0d Mon Sep 17 00:00:00 2001 From: Emma Lejeck Date: Sun, 17 Sep 2023 19:57:39 -0700 Subject: [PATCH] Add page/per pagination in SearchService --- app/services/search_service/dsl.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/services/search_service/dsl.rb b/app/services/search_service/dsl.rb index 03dc6fc37d..e7ae6b6aa5 100644 --- a/app/services/search_service/dsl.rb +++ b/app/services/search_service/dsl.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Provides the DSL-like interactive query methods for SearchServices class SearchService module DSL @@ -15,7 +17,7 @@ module DSL # @return [Integer] the offset for pagination # @!attribute [r] _limit # @return [Integer] the number of items to return on this page - attr_reader :_queries, :_filters, :_includes, :_order, :_offset, :_limit + attr_reader :_queries, :_filters, :_includes, :_order, :_offset, :_limit, :_page, :_per # Set up a Search with queries and filters to be applied to the request # @@ -60,5 +62,21 @@ def limit(limit) @_limit = limit self end + + # Set the page number to return + # + # @param [Integer] the page number to return + def page(page) + @_page = page + self + end + + # Set the number of items to return on each page + # + # @param [Integer] the number of items to return on each page + def per(per) + @_per = per + self + end end end