Commit 74c758d20af82d27c30a267145e947ed2056f7e6
1 parent
917d0ef3
Exists in
master
and in
21 other branches
Added total_entries method
Showing
2 changed files
with
3 additions
and
4 deletions
Show diff stats
lib/searchkick/results.rb
... | ... | @@ -63,6 +63,7 @@ module Searchkick |
63 | 63 | def total_count |
64 | 64 | response["hits"]["total"] |
65 | 65 | end |
66 | + alias_method :total_entries, :total_count | |
66 | 67 | |
67 | 68 | def current_page |
68 | 69 | options[:page] |
... | ... | @@ -71,15 +72,12 @@ module Searchkick |
71 | 72 | def per_page |
72 | 73 | options[:per_page] |
73 | 74 | end |
75 | + alias_method :limit_value, :per_page | |
74 | 76 | |
75 | 77 | def total_pages |
76 | 78 | (total_count / per_page.to_f).ceil |
77 | 79 | end |
78 | 80 | |
79 | - def limit_value | |
80 | - per_page | |
81 | - end | |
82 | - | |
83 | 81 | def offset_value |
84 | 82 | current_page * per_page |
85 | 83 | end | ... | ... |
test/sql_test.rb
... | ... | @@ -26,6 +26,7 @@ class TestSql < Minitest::Unit::TestCase |
26 | 26 | assert_equal 2, products.per_page |
27 | 27 | assert_equal 3, products.total_pages |
28 | 28 | assert_equal 5, products.total_count |
29 | + assert_equal 5, products.total_entries | |
29 | 30 | assert_equal 2, products.limit_value |
30 | 31 | assert_equal 4, products.offset_value |
31 | 32 | end | ... | ... |