Commit 4a8119750e34ac280ef6e68234f28184b3ba8c41
1 parent
ed7bfccb
Exists in
master
and in
28 other branches
Return facets with option enabled
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
app/models/environment_finder.rb
... | ... | @@ -49,13 +49,19 @@ class EnvironmentFinder |
49 | 49 | end |
50 | 50 | else |
51 | 51 | pg_options = {:page => options.delete(:page), :per_page => options.delete(:per_page)} |
52 | + solr_options = {:facets => options.delete(:facets)} | |
52 | 53 | if product_category && asset == :products |
53 | 54 | # SECURITY no risk of SQL injection, since product_category_ids comes from trusted source |
54 | - @environment.send(asset).find_by_contents(query, pg_options, {}, options.merge({:include => 'product_categorizations', :conditions => 'product_categorizations.category_id = (%s)' % product_category.id }))[:results] | |
55 | + ret = @environment.send(asset).find_by_contents(query, pg_options, solr_options, options.merge({:include => 'product_categorizations', :conditions => 'product_categorizations.category_id = (%s)' % product_category.id })) | |
55 | 56 | elsif product_category && asset == :enterprises |
56 | - @environment.send(asset).find_by_contents(query, pg_options, {}, options.merge(:joins => 'inner join product_categorizations on (product_categorizations.product_id = products.id)', :include => 'products', :conditions => "product_categorizations.category_id = (#{product_category.id})"))[:results] | |
57 | + ret = @environment.send(asset).find_by_contents(query, pg_options, solr_options, options.merge(:joins => 'inner join product_categorizations on (product_categorizations.product_id = products.id)', :include => 'products', :conditions => "product_categorizations.category_id = (#{product_category.id})")) | |
57 | 58 | else |
58 | - @environment.send(asset).find_by_contents(query, pg_options, {}, options)[:results] | |
59 | + ret = @environment.send(asset).find_by_contents(query, pg_options, solr_options, options) | |
60 | + end | |
61 | + if solr_options[:facets].nil? | |
62 | + ret[:results] | |
63 | + else | |
64 | + ret | |
59 | 65 | end |
60 | 66 | end |
61 | 67 | end | ... | ... |