Commit f2bf49d5f553a0afc60dcc4b91ed91d5bb421e92
1 parent
56f7c497
Exists in
master
and in
28 other branches
[pluginize-solr] Moving {name,price}_sortable attributes
Obs: Must move the search_helper now.
Showing
9 changed files
with
32 additions
and
41 deletions
Show diff stats
app/helpers/search_helper.rb
... | ... | @@ -19,26 +19,26 @@ module SearchHelper |
19 | 19 | SortOptions = { |
20 | 20 | :products => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
21 | 21 | :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, |
22 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
22 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
23 | 23 | :closest, {:label => _('Closest to me'), :if => proc{ logged_in? && (profile=current_user.person).lat && profile.lng }, |
24 | 24 | :solr_opts => {:sort => "geodist() asc", |
25 | 25 | :latitude => proc{ current_user.person.lat }, :longitude => proc{ current_user.person.lng }}}, |
26 | 26 | ], |
27 | 27 | :events => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
28 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
28 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
29 | 29 | ], |
30 | 30 | :articles => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
31 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
31 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
32 | 32 | :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, |
33 | 33 | ], |
34 | 34 | :enterprises => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
35 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
35 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
36 | 36 | ], |
37 | 37 | :people => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
38 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
38 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
39 | 39 | ], |
40 | 40 | :communities => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
41 | - :name, {:label => _('Name'), :solr_opts => {:sort => 'name_sortable asc'}}, | |
41 | + :name, {:label => _('Name'), :solr_opts => {:sort => 'solr_plugin_name_sortable asc'}}, | |
42 | 42 | ], |
43 | 43 | } |
44 | 44 | ... | ... |
app/models/article.rb
... | ... | @@ -648,10 +648,6 @@ class Article < ActiveRecord::Base |
648 | 648 | Event |
649 | 649 | |
650 | 650 | delegate :region, :region_id, :environment, :environment_id, :to => :profile, :allow_nil => true |
651 | - def name_sortable # give a different name for solr | |
652 | - name | |
653 | - end | |
654 | - | |
655 | 651 | public |
656 | 652 | handle_asynchronously :solr_save |
657 | 653 | ... | ... |
app/models/category.rb
... | ... | @@ -90,11 +90,6 @@ class Category < ActiveRecord::Base |
90 | 90 | self.children.find(:all, :conditions => {:display_in_menu => true}).empty? |
91 | 91 | end |
92 | 92 | |
93 | - private | |
94 | - def name_sortable # give a different name for solr | |
95 | - name | |
96 | - end | |
97 | - public | |
98 | 93 | handle_asynchronously :solr_save |
99 | 94 | |
100 | 95 | end | ... | ... |
app/models/product.rb
... | ... | @@ -211,21 +211,7 @@ class Product < ActiveRecord::Base |
211 | 211 | end |
212 | 212 | end |
213 | 213 | |
214 | - private | |
215 | - | |
216 | 214 | delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise |
217 | - | |
218 | - alias_method :name_sortable, :name | |
219 | - def name_sortable # give a different name for solr | |
220 | - name | |
221 | - end | |
222 | - | |
223 | - def price_sortable | |
224 | - (price.nil? or price.zero?) ? nil : price | |
225 | - end | |
226 | - | |
227 | - public | |
228 | - | |
229 | 215 | handle_asynchronously :solr_save |
230 | 216 | |
231 | 217 | end | ... | ... |
app/models/profile.rb
... | ... | @@ -874,14 +874,6 @@ private :generate_url, :url_options |
874 | 874 | self.active_fields |
875 | 875 | end |
876 | 876 | |
877 | - private | |
878 | - | |
879 | - def name_sortable # give a different name for solr | |
880 | - name | |
881 | - end | |
882 | - | |
883 | - public | |
884 | - | |
885 | 877 | handle_asynchronously :solr_save |
886 | 878 | |
887 | 879 | def control_panel_settings_button | ... | ... |
plugins/solr/lib/ext/article.rb
... | ... | @@ -25,7 +25,7 @@ class Article |
25 | 25 | {:profile_id => :integer}, :language, |
26 | 26 | {:solr_plugin_category_filter => :integer}, |
27 | 27 | # ordered/query-boosted fields |
28 | - {:name_sortable => :string}, :last_changed_by_id, :published_at, :is_image, | |
28 | + {:solr_plugin_name_sortable => :string}, :last_changed_by_id, :published_at, :is_image, | |
29 | 29 | :updated_at, :created_at, |
30 | 30 | ], :include => [ |
31 | 31 | {:profile => {:fields => [:name, :identifier, :address, :nickname, :region_id, :lat, :lng]}}, |
... | ... | @@ -74,4 +74,8 @@ class Article |
74 | 74 | def solr_plugin_category_filter |
75 | 75 | categories_including_virtual_ids |
76 | 76 | end |
77 | + | |
78 | + def solr_plugin_name_sortable | |
79 | + name | |
80 | + end | |
77 | 81 | end | ... | ... |
plugins/solr/lib/ext/category.rb
... | ... | @@ -11,6 +11,12 @@ class Category |
11 | 11 | # filtered fields |
12 | 12 | :parent_id, |
13 | 13 | # ordered/query-boosted fields |
14 | - {:name_sortable => :string}, | |
14 | + {:solr_plugin_name_sortable => :string}, | |
15 | 15 | ] |
16 | + | |
17 | + private | |
18 | + | |
19 | + def solr_plugin_name_sortable | |
20 | + name | |
21 | + end | |
16 | 22 | end | ... | ... |
plugins/solr/lib/ext/product.rb
... | ... | @@ -30,7 +30,7 @@ class Product |
30 | 30 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, |
31 | 31 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, |
32 | 32 | # ordered/query-boosted fields |
33 | - {:price_sortable => :decimal}, {:name_sortable => :string}, | |
33 | + {:solr_plugin_price_sortable => :decimal}, {:solr_plugin_name_sortable => :string}, | |
34 | 34 | {:lat => :float}, {:lng => :float}, |
35 | 35 | :updated_at, :created_at, |
36 | 36 | ], :include => [ |
... | ... | @@ -82,4 +82,12 @@ class Product |
82 | 82 | def solr_plugin_public |
83 | 83 | self.public? |
84 | 84 | end |
85 | + | |
86 | + def solr_plugin_name_sortable # give a different name for solr | |
87 | + name | |
88 | + end | |
89 | + | |
90 | + def solr_plugin_price_sortable | |
91 | + (price.nil? or price.zero?) ? nil : price | |
92 | + end | |
85 | 93 | end | ... | ... |
plugins/solr/lib/ext/profile.rb
... | ... | @@ -20,7 +20,7 @@ class Profile |
20 | 20 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, |
21 | 21 | {:solr_plugin_category_filter => :integer}, |
22 | 22 | # ordered/query-boosted fields |
23 | - {:name_sortable => :string}, {:user_id => :integer}, | |
23 | + {:solr_plugin_name_sortable => :string}, {:user_id => :integer}, | |
24 | 24 | :enabled, :active, :validated, :public_profile, |
25 | 25 | {:lat => :float}, {:lng => :float}, |
26 | 26 | :updated_at, :created_at, |
... | ... | @@ -94,4 +94,8 @@ class Profile |
94 | 94 | def solr_plugin_category_filter |
95 | 95 | categories_including_virtual_ids |
96 | 96 | end |
97 | + | |
98 | + def solr_plugin_name_sortable | |
99 | + name | |
100 | + end | |
97 | 101 | end | ... | ... |