Skip to content

Commit

Permalink
Add page/per pagination in SearchService
Browse files Browse the repository at this point in the history
  • Loading branch information
NuckChorris committed Sep 18, 2023
1 parent 1bfacd1 commit f022d38
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/services/search_service/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Provides the DSL-like interactive query methods for SearchServices
class SearchService
module DSL
Expand All @@ -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
#
Expand Down Expand Up @@ -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

0 comments on commit f022d38

Please sign in to comment.