Commit 1b6b699fa992fbead80d228190502330b645b2cb
1 parent
577cdbee
Exists in
master
and in
29 other branches
Check for public instead of visible
Also only search on the current environment
Showing
4 changed files
with
28 additions
and
7 deletions
Show diff stats
app/controllers/public/search_controller.rb
@@ -44,7 +44,7 @@ class SearchController < PublicController | @@ -44,7 +44,7 @@ class SearchController < PublicController | ||
44 | 44 | ||
45 | def people | 45 | def people |
46 | if !@empty_query | 46 | if !@empty_query |
47 | - full_text_search ['visible:true'] | 47 | + full_text_search ['public:true'] |
48 | else | 48 | else |
49 | @results[@asset] = @environment.people.visible.send(@filter).paginate(paginate_options) | 49 | @results[@asset] = @environment.people.visible.send(@filter).paginate(paginate_options) |
50 | @facets = {} | 50 | @facets = {} |
@@ -53,13 +53,13 @@ class SearchController < PublicController | @@ -53,13 +53,13 @@ class SearchController < PublicController | ||
53 | 53 | ||
54 | def products | 54 | def products |
55 | if !@empty_query | 55 | if !@empty_query |
56 | - full_text_search ['visible:true'] | 56 | + full_text_search ['public:true'] |
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
60 | def enterprises | 60 | def enterprises |
61 | if !@empty_query | 61 | if !@empty_query |
62 | - full_text_search ['visible:true'] | 62 | + full_text_search ['public:true'] |
63 | else | 63 | else |
64 | @filter_title = _('Enterprises from network') | 64 | @filter_title = _('Enterprises from network') |
65 | @results[@asset] = @environment.enterprises.visible.paginate(paginate_options) | 65 | @results[@asset] = @environment.enterprises.visible.paginate(paginate_options) |
@@ -68,7 +68,7 @@ class SearchController < PublicController | @@ -68,7 +68,7 @@ class SearchController < PublicController | ||
68 | 68 | ||
69 | def communities | 69 | def communities |
70 | if !@empty_query | 70 | if !@empty_query |
71 | - full_text_search ['visible:true'] | 71 | + full_text_search ['public:true'] |
72 | else | 72 | else |
73 | @results[@asset] = @environment.communities.visible.send(@filter).paginate(paginate_options) | 73 | @results[@asset] = @environment.communities.visible.send(@filter).paginate(paginate_options) |
74 | end | 74 | end |
@@ -291,6 +291,7 @@ class SearchController < PublicController | @@ -291,6 +291,7 @@ class SearchController < PublicController | ||
291 | solr_options[:order] = params[:order_by] if params[:order_by] | 291 | solr_options[:order] = params[:order_by] if params[:order_by] |
292 | solr_options[:filter_queries] ||= [] | 292 | solr_options[:filter_queries] ||= [] |
293 | solr_options[:filter_queries] += filters | 293 | solr_options[:filter_queries] += filters |
294 | + solr_options[:filter_queries] << "environment_id:#{environment.id}" | ||
294 | 295 | ||
295 | ret = asset_class.find_by_contents(@query, paginate_options, solr_options) | 296 | ret = asset_class.find_by_contents(@query, paginate_options, solr_options) |
296 | @results[@asset] = ret[:results] | 297 | @results[@asset] = ret[:results] |
app/models/article.rb
@@ -627,6 +627,9 @@ class Article < ActiveRecord::Base | @@ -627,6 +627,9 @@ class Article < ActiveRecord::Base | ||
627 | def public | 627 | def public |
628 | self.public? | 628 | self.public? |
629 | end | 629 | end |
630 | + def environment_id | ||
631 | + profile.environment_id | ||
632 | + end | ||
630 | public | 633 | public |
631 | 634 | ||
632 | acts_as_faceted :fields => { | 635 | acts_as_faceted :fields => { |
@@ -639,7 +642,11 @@ class Article < ActiveRecord::Base | @@ -639,7 +642,11 @@ class Article < ActiveRecord::Base | ||
639 | :category_query => proc { |c| "f_category:\"#{c.name}\"" }, | 642 | :category_query => proc { |c| "f_category:\"#{c.name}\"" }, |
640 | :order => [:f_type, :f_published_at, :f_profile_type, :f_category] | 643 | :order => [:f_type, :f_published_at, :f_profile_type, :f_category] |
641 | 644 | ||
642 | - acts_as_searchable :additional_fields => [ {:name => {:type => :string}}, {:public => {:type => :boolean}}] + facets_fields_for_solr, | 645 | + acts_as_searchable :additional_fields => [ |
646 | + {:name => {:type => :string}}, | ||
647 | + {:public => {:type => :boolean}}, | ||
648 | + {:environment_id => {:type => :integer}}, | ||
649 | + ] + facets_fields_for_solr, | ||
643 | :exclude_fields => [:setting], | 650 | :exclude_fields => [:setting], |
644 | :include => [:profile], | 651 | :include => [:profile], |
645 | :facets => facets_option_for_solr, | 652 | :facets => facets_option_for_solr, |
app/models/product.rb
@@ -93,7 +93,7 @@ class Product < ActiveRecord::Base | @@ -93,7 +93,7 @@ class Product < ActiveRecord::Base | ||
93 | end | 93 | end |
94 | 94 | ||
95 | def public? | 95 | def public? |
96 | - enterprise.public_profile | 96 | + enterprise.public? |
97 | end | 97 | end |
98 | 98 | ||
99 | def formatted_value(value) | 99 | def formatted_value(value) |
@@ -181,6 +181,12 @@ class Product < ActiveRecord::Base | @@ -181,6 +181,12 @@ class Product < ActiveRecord::Base | ||
181 | def f_qualifier | 181 | def f_qualifier |
182 | product_qualifier_ids | 182 | product_qualifier_ids |
183 | end | 183 | end |
184 | + def public | ||
185 | + self.public? | ||
186 | + end | ||
187 | + def environment_id | ||
188 | + enterprise.environment_id | ||
189 | + end | ||
184 | public | 190 | public |
185 | 191 | ||
186 | acts_as_faceted :fields => { | 192 | acts_as_faceted :fields => { |
@@ -193,6 +199,8 @@ class Product < ActiveRecord::Base | @@ -193,6 +199,8 @@ class Product < ActiveRecord::Base | ||
193 | acts_as_searchable :additional_fields => [ | 199 | acts_as_searchable :additional_fields => [ |
194 | {:name => {:type => :text, :boost => 5.0}}, | 200 | {:name => {:type => :text, :boost => 5.0}}, |
195 | {:price_sort => {:type => :decimal}}, | 201 | {:price_sort => {:type => :decimal}}, |
202 | + {:public => {:type => :boolean}}, | ||
203 | + {:environment_id => {:type => :integer}}, | ||
196 | {:name_or_category => {:type => :string, :as => :name_or_category_sort, :boost => 2.0}}, | 204 | {:name_or_category => {:type => :string, :as => :name_or_category_sort, :boost => 2.0}}, |
197 | :category_full_name ] + facets.keys.map{|i| {i => :facet}}, | 205 | :category_full_name ] + facets.keys.map{|i| {i => :facet}}, |
198 | :include => [:enterprise, :qualifiers, :certifiers, :product_category], | 206 | :include => [:enterprise, :qualifiers, :certifiers, :product_category], |
app/models/profile.rb
@@ -851,6 +851,9 @@ private :generate_url, :url_options | @@ -851,6 +851,9 @@ private :generate_url, :url_options | ||
851 | def name_sort | 851 | def name_sort |
852 | name | 852 | name |
853 | end | 853 | end |
854 | + def public | ||
855 | + self.public? | ||
856 | + end | ||
854 | public | 857 | public |
855 | 858 | ||
856 | acts_as_faceted :fields => { | 859 | acts_as_faceted :fields => { |
@@ -861,7 +864,9 @@ private :generate_url, :url_options | @@ -861,7 +864,9 @@ private :generate_url, :url_options | ||
861 | :order => [:f_type, :f_categories] | 864 | :order => [:f_type, :f_categories] |
862 | 865 | ||
863 | acts_as_searchable :additional_fields => [ | 866 | acts_as_searchable :additional_fields => [ |
864 | - :extra_data_for_index, {:name_sort => {:type => :string}} ] + facets.keys.map{|i| {i => :facet}}, | 867 | + {:name_sort => {:type => :string}}, |
868 | + {:public => {:type => :boolean}}, | ||
869 | + :extra_data_for_index ] + facets.keys.map{|i| {i => :facet}}, | ||
865 | :boost => proc {|p| 10 if p.enabled}, | 870 | :boost => proc {|p| 10 if p.enabled}, |
866 | :facets => facets.keys | 871 | :facets => facets.keys |
867 | handle_asynchronously :solr_save | 872 | handle_asynchronously :solr_save |