Commit 1aaa6fa716755f9e02c693372cdf5a62eef638ec

Authored by Rodrigo Souto
1 parent f4be5188

[pluginize-solr] Moving handle_asynchronously solr save

app/models/article.rb
@@ -648,8 +648,6 @@ class Article < ActiveRecord::Base @@ -648,8 +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 - public  
652 - handle_asynchronously :solr_save  
653 651
654 private 652 private
655 653
app/models/category.rb
@@ -90,6 +90,4 @@ class Category < ActiveRecord::Base @@ -90,6 +90,4 @@ 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 - handle_asynchronously :solr_save  
94 -  
95 end 93 end
app/models/product.rb
@@ -212,6 +212,5 @@ class Product < ActiveRecord::Base @@ -212,6 +212,5 @@ class Product < ActiveRecord::Base
212 end 212 end
213 213
214 delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise 214 delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise
215 - handle_asynchronously :solr_save  
216 215
217 end 216 end
app/models/profile.rb
@@ -874,8 +874,6 @@ private :generate_url, :url_options @@ -874,8 +874,6 @@ private :generate_url, :url_options
874 self.active_fields 874 self.active_fields
875 end 875 end
876 876
877 - handle_asynchronously :solr_save  
878 -  
879 def control_panel_settings_button 877 def control_panel_settings_button
880 {:title => _('Profile Info and settings'), :icon => 'edit-profile'} 878 {:title => _('Profile Info and settings'), :icon => 'edit-profile'}
881 end 879 end
plugins/solr/lib/ext/article.rb
1 require_dependency 'article' 1 require_dependency 'article'
2 2
3 class Article 3 class Article
4 - def solr_plugin_comments_updated  
5 - solr_save  
6 - end 4 +
  5 + handle_asynchronously :solr_save
7 6
8 acts_as_faceted :fields => { 7 acts_as_faceted :fields => {
9 :solr_plugin_f_type => {:label => _('Type'), :proc => proc{|klass| solr_plugin_f_type_proc(klass)}}, 8 :solr_plugin_f_type => {:label => _('Type'), :proc => proc{|klass| solr_plugin_f_type_proc(klass)}},
@@ -35,6 +34,10 @@ class Article @@ -35,6 +34,10 @@ class Article
35 :boost => proc { |a| 10 if a.profile && a.profile.enabled }, 34 :boost => proc { |a| 10 if a.profile && a.profile.enabled },
36 :if => proc{ |a| ! ['RssFeed'].include?(a.class.name) } 35 :if => proc{ |a| ! ['RssFeed'].include?(a.class.name) }
37 36
  37 + def solr_plugin_comments_updated
  38 + solr_save
  39 + end
  40 +
38 private 41 private
39 42
40 def self.solr_plugin_f_type_proc(klass) 43 def self.solr_plugin_f_type_proc(klass)
plugins/solr/lib/ext/category.rb
@@ -2,6 +2,7 @@ require_dependency 'category' @@ -2,6 +2,7 @@ require_dependency 'category'
2 2
3 class Category 3 class Category
4 after_save_reindex [:articles, :profiles], :with => :delayed_job 4 after_save_reindex [:articles, :profiles], :with => :delayed_job
  5 + handle_asynchronously :solr_save
5 6
6 acts_as_searchable :fields => [ 7 acts_as_searchable :fields => [
7 # searched fields 8 # searched fields
plugins/solr/lib/ext/product.rb
@@ -2,6 +2,7 @@ require_dependency 'product' @@ -2,6 +2,7 @@ require_dependency 'product'
2 2
3 class Product 3 class Product
4 after_save_reindex [:enterprise], :with => :delayed_job 4 after_save_reindex [:enterprise], :with => :delayed_job
  5 + handle_asynchronously :solr_save
5 6
6 acts_as_faceted :fields => { 7 acts_as_faceted :fields => {
7 :solr_plugin_f_category => {:label => _('Related products')}, 8 :solr_plugin_f_category => {:label => _('Related products')},
plugins/solr/lib/ext/profile.rb
@@ -2,6 +2,7 @@ require_dependency 'profile' @@ -2,6 +2,7 @@ require_dependency 'profile'
2 2
3 class Profile 3 class Profile
4 after_save_reindex [:articles], :with => :delayed_job 4 after_save_reindex [:articles], :with => :delayed_job
  5 + handle_asynchronously :solr_save
5 6
6 acts_as_faceted :fields => { 7 acts_as_faceted :fields => {
7 :solr_plugin_f_enabled => {:label => _('Situation'), :type_if => proc { |klass| klass.kind_of?(Enterprise) }, 8 :solr_plugin_f_enabled => {:label => _('Situation'), :type_if => proc { |klass| klass.kind_of?(Enterprise) },