Commit ed7bfccbadbeddbb9dac3a77c209ed3e8f590a0b
1 parent
31491cc8
Exists in
master
and in
22 other branches
Avoid double pagination on find_by_contents
Only paginate with pg_options was given. This fixes a bug on the browse controller where not all results were shown.
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
lib/acts_as_searchable.rb
| ... | ... | @@ -29,7 +29,6 @@ module ActsAsSearchable |
| 29 | 29 | end |
| 30 | 30 | |
| 31 | 31 | def find_by_contents(query, pg_options = {}, options = {}, db_options = {}) |
| 32 | - pg_options[:page] ||= 1 | |
| 33 | 32 | options[:limit] = 1000000; |
| 34 | 33 | options[:scores] = true; |
| 35 | 34 | |
| ... | ... | @@ -40,7 +39,7 @@ module ActsAsSearchable |
| 40 | 39 | else |
| 41 | 40 | facets = options.include?(:facets) ? solr_result.facets : {} |
| 42 | 41 | if db_options.empty? |
| 43 | - results = solr_result.results.paginate(pg_options) | |
| 42 | + results = solr_result.results | |
| 44 | 43 | else |
| 45 | 44 | ids = solr_result.results.map{|r|r[:id].to_i} |
| 46 | 45 | if ids.empty? |
| ... | ... | @@ -53,11 +52,14 @@ module ActsAsSearchable |
| 53 | 52 | db_options[:conditions] = "#{table_name}.id in (#{ids.join(', ')})" |
| 54 | 53 | end |
| 55 | 54 | |
| 56 | - result = find(:all, db_options) | |
| 57 | - results = result.paginate(pg_options) | |
| 55 | + results = find(:all, db_options) | |
| 58 | 56 | end |
| 59 | 57 | end |
| 60 | 58 | |
| 59 | + if !pg_options.empty? | |
| 60 | + pg_options[:page] ||= 1 | |
| 61 | + results = results.paginate(pg_options) | |
| 62 | + end | |
| 61 | 63 | {:results => results, :facets => facets} |
| 62 | 64 | end |
| 63 | 65 | end | ... | ... |