Commit f2bf49d5f553a0afc60dcc4b91ed91d5bb421e92
1 parent
56f7c497
Exists in
master
and in
23 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,26 +19,26 @@ module SearchHelper | ||
| 19 | SortOptions = { | 19 | SortOptions = { |
| 20 | :products => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 20 | :products => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, |
| 21 | :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, | 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 | :closest, {:label => _('Closest to me'), :if => proc{ logged_in? && (profile=current_user.person).lat && profile.lng }, | 23 | :closest, {:label => _('Closest to me'), :if => proc{ logged_in? && (profile=current_user.person).lat && profile.lng }, |
| 24 | :solr_opts => {:sort => "geodist() asc", | 24 | :solr_opts => {:sort => "geodist() asc", |
| 25 | :latitude => proc{ current_user.person.lat }, :longitude => proc{ current_user.person.lng }}}, | 25 | :latitude => proc{ current_user.person.lat }, :longitude => proc{ current_user.person.lng }}}, |
| 26 | ], | 26 | ], |
| 27 | :events => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 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 | :articles => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 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 | :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, | 32 | :more_recent, {:label => _('More recent'), :solr_opts => {:sort => 'updated_at desc, score desc'}}, |
| 33 | ], | 33 | ], |
| 34 | :enterprises => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 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 | :people => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 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 | :communities => ActiveSupport::OrderedHash[ :none, {:label => _('Relevance')}, | 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,10 +648,6 @@ class Article < ActiveRecord::Base | ||
| 648 | Event | 648 | Event |
| 649 | 649 | ||
| 650 | delegate :region, :region_id, :environment, :environment_id, :to => :profile, :allow_nil => true | 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 | public | 651 | public |
| 656 | handle_asynchronously :solr_save | 652 | handle_asynchronously :solr_save |
| 657 | 653 |
app/models/category.rb
| @@ -90,11 +90,6 @@ class Category < ActiveRecord::Base | @@ -90,11 +90,6 @@ class Category < ActiveRecord::Base | ||
| 90 | self.children.find(:all, :conditions => {:display_in_menu => true}).empty? | 90 | self.children.find(:all, :conditions => {:display_in_menu => true}).empty? |
| 91 | end | 91 | end |
| 92 | 92 | ||
| 93 | - private | ||
| 94 | - def name_sortable # give a different name for solr | ||
| 95 | - name | ||
| 96 | - end | ||
| 97 | - public | ||
| 98 | handle_asynchronously :solr_save | 93 | handle_asynchronously :solr_save |
| 99 | 94 | ||
| 100 | end | 95 | end |
app/models/product.rb
| @@ -211,21 +211,7 @@ class Product < ActiveRecord::Base | @@ -211,21 +211,7 @@ class Product < ActiveRecord::Base | ||
| 211 | end | 211 | end |
| 212 | end | 212 | end |
| 213 | 213 | ||
| 214 | - private | ||
| 215 | - | ||
| 216 | delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise | 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 | handle_asynchronously :solr_save | 215 | handle_asynchronously :solr_save |
| 230 | 216 | ||
| 231 | end | 217 | end |
app/models/profile.rb
| @@ -874,14 +874,6 @@ private :generate_url, :url_options | @@ -874,14 +874,6 @@ private :generate_url, :url_options | ||
| 874 | self.active_fields | 874 | self.active_fields |
| 875 | end | 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 | handle_asynchronously :solr_save | 877 | handle_asynchronously :solr_save |
| 886 | 878 | ||
| 887 | def control_panel_settings_button | 879 | def control_panel_settings_button |
plugins/solr/lib/ext/article.rb
| @@ -25,7 +25,7 @@ class Article | @@ -25,7 +25,7 @@ class Article | ||
| 25 | {:profile_id => :integer}, :language, | 25 | {:profile_id => :integer}, :language, |
| 26 | {:solr_plugin_category_filter => :integer}, | 26 | {:solr_plugin_category_filter => :integer}, |
| 27 | # ordered/query-boosted fields | 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 | :updated_at, :created_at, | 29 | :updated_at, :created_at, |
| 30 | ], :include => [ | 30 | ], :include => [ |
| 31 | {:profile => {:fields => [:name, :identifier, :address, :nickname, :region_id, :lat, :lng]}}, | 31 | {:profile => {:fields => [:name, :identifier, :address, :nickname, :region_id, :lat, :lng]}}, |
| @@ -74,4 +74,8 @@ class Article | @@ -74,4 +74,8 @@ class Article | ||
| 74 | def solr_plugin_category_filter | 74 | def solr_plugin_category_filter |
| 75 | categories_including_virtual_ids | 75 | categories_including_virtual_ids |
| 76 | end | 76 | end |
| 77 | + | ||
| 78 | + def solr_plugin_name_sortable | ||
| 79 | + name | ||
| 80 | + end | ||
| 77 | end | 81 | end |
plugins/solr/lib/ext/category.rb
| @@ -11,6 +11,12 @@ class Category | @@ -11,6 +11,12 @@ class Category | ||
| 11 | # filtered fields | 11 | # filtered fields |
| 12 | :parent_id, | 12 | :parent_id, |
| 13 | # ordered/query-boosted fields | 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 | end | 22 | end |
plugins/solr/lib/ext/product.rb
| @@ -30,7 +30,7 @@ class Product | @@ -30,7 +30,7 @@ class Product | ||
| 30 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, | 30 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, |
| 31 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, | 31 | {:enabled => :boolean}, {:solr_plugin_category_filter => :integer}, |
| 32 | # ordered/query-boosted fields | 32 | # ordered/query-boosted fields |
| 33 | - {:price_sortable => :decimal}, {:name_sortable => :string}, | 33 | + {:solr_plugin_price_sortable => :decimal}, {:solr_plugin_name_sortable => :string}, |
| 34 | {:lat => :float}, {:lng => :float}, | 34 | {:lat => :float}, {:lng => :float}, |
| 35 | :updated_at, :created_at, | 35 | :updated_at, :created_at, |
| 36 | ], :include => [ | 36 | ], :include => [ |
| @@ -82,4 +82,12 @@ class Product | @@ -82,4 +82,12 @@ class Product | ||
| 82 | def solr_plugin_public | 82 | def solr_plugin_public |
| 83 | self.public? | 83 | self.public? |
| 84 | end | 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 | end | 93 | end |
plugins/solr/lib/ext/profile.rb
| @@ -20,7 +20,7 @@ class Profile | @@ -20,7 +20,7 @@ class Profile | ||
| 20 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, | 20 | {:solr_plugin_public => :boolean}, {:environment_id => :integer}, |
| 21 | {:solr_plugin_category_filter => :integer}, | 21 | {:solr_plugin_category_filter => :integer}, |
| 22 | # ordered/query-boosted fields | 22 | # ordered/query-boosted fields |
| 23 | - {:name_sortable => :string}, {:user_id => :integer}, | 23 | + {:solr_plugin_name_sortable => :string}, {:user_id => :integer}, |
| 24 | :enabled, :active, :validated, :public_profile, | 24 | :enabled, :active, :validated, :public_profile, |
| 25 | {:lat => :float}, {:lng => :float}, | 25 | {:lat => :float}, {:lng => :float}, |
| 26 | :updated_at, :created_at, | 26 | :updated_at, :created_at, |
| @@ -94,4 +94,8 @@ class Profile | @@ -94,4 +94,8 @@ class Profile | ||
| 94 | def solr_plugin_category_filter | 94 | def solr_plugin_category_filter |
| 95 | categories_including_virtual_ids | 95 | categories_including_virtual_ids |
| 96 | end | 96 | end |
| 97 | + | ||
| 98 | + def solr_plugin_name_sortable | ||
| 99 | + name | ||
| 100 | + end | ||
| 97 | end | 101 | end |