Commit 4a8119750e34ac280ef6e68234f28184b3ba8c41
1 parent
ed7bfccb
Exists in
staging
and in
42 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,13 +49,19 @@ class EnvironmentFinder | ||
49 | end | 49 | end |
50 | else | 50 | else |
51 | pg_options = {:page => options.delete(:page), :per_page => options.delete(:per_page)} | 51 | pg_options = {:page => options.delete(:page), :per_page => options.delete(:per_page)} |
52 | + solr_options = {:facets => options.delete(:facets)} | ||
52 | if product_category && asset == :products | 53 | if product_category && asset == :products |
53 | # SECURITY no risk of SQL injection, since product_category_ids comes from trusted source | 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 | elsif product_category && asset == :enterprises | 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 | else | 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 | end | 65 | end |
60 | end | 66 | end |
61 | end | 67 | end |