Commit 4008b724b3e74e37476d7b8eac7efa2725464086
1 parent
400664f1
Exists in
master
and in
21 other branches
Better results
Showing
2 changed files
with
11 additions
and
5 deletions
Show diff stats
lib/searchkick/query.rb
@@ -338,13 +338,12 @@ module Searchkick | @@ -338,13 +338,12 @@ module Searchkick | ||
338 | end | 338 | end |
339 | 339 | ||
340 | opts = { | 340 | opts = { |
341 | + page: @page, | ||
342 | + per_page: @per_page, | ||
341 | load: @load, | 343 | load: @load, |
342 | includes: options[:include] || options[:includes] | 344 | includes: options[:include] || options[:includes] |
343 | } | 345 | } |
344 | - results = Searchkick::Results.new(searchkick_klass, response, opts) | ||
345 | - results.current_page = @page | ||
346 | - results.per_page = @per_page | ||
347 | - results | 346 | + Searchkick::Results.new(searchkick_klass, response, opts) |
348 | end | 347 | end |
349 | 348 | ||
350 | private | 349 | private |
lib/searchkick/results.rb
@@ -4,7 +4,6 @@ module Searchkick | @@ -4,7 +4,6 @@ module Searchkick | ||
4 | extend Forwardable | 4 | extend Forwardable |
5 | 5 | ||
6 | attr_reader :klass, :response, :options | 6 | attr_reader :klass, :response, :options |
7 | - attr_accessor :current_page, :per_page | ||
8 | 7 | ||
9 | def_delegators :results, :each, :empty?, :size, :slice, :[], :to_ary | 8 | def_delegators :results, :each, :empty?, :size, :slice, :[], :to_ary |
10 | 9 | ||
@@ -65,6 +64,14 @@ module Searchkick | @@ -65,6 +64,14 @@ module Searchkick | ||
65 | response["hits"]["total"] | 64 | response["hits"]["total"] |
66 | end | 65 | end |
67 | 66 | ||
67 | + def current_page | ||
68 | + options[:page] | ||
69 | + end | ||
70 | + | ||
71 | + def per_page | ||
72 | + options[:per_page] | ||
73 | + end | ||
74 | + | ||
68 | def total_pages | 75 | def total_pages |
69 | (total_count / per_page.to_f).ceil | 76 | (total_count / per_page.to_f).ceil |
70 | end | 77 | end |