[Git][noosfero/noosfero][stable] 2 commits: Fix crash on solr indexation

Bráulio Bhavamitra gitlab at gitlab.com
Wed Jun 17 20:40:28 BRT 2015


Bráulio Bhavamitra pushed to branch stable at Noosfero / noosfero


Commits:
b7a016fd by Braulio Bhavamitra at 2014-08-08T10:38:58Z
Fix crash on solr indexation

(ActionItem3270)

- - - - -
b399a2bf by Bráulio Bhavamitra at 2015-06-17T23:40:13Z
Merge branch 'ai3270' into 'stable'

Fix product solr indexation

http://noosfero.org/Development/ActionItem3270

See merge request !297

- - - - -


2 changed files:

- app/models/product.rb
- plugins/solr/lib/ext/product.rb


Changes:

=====================================
app/models/product.rb
=====================================
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -249,7 +249,7 @@ class Product < ActiveRecord::Base
         end
   end
 
-  delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise
+  delegate :enabled, :region, :region_id, :environment, :environment_id, :to => :enterprise, :allow_nil => true
 
   protected
 


=====================================
plugins/solr/lib/ext/product.rb
=====================================
--- a/plugins/solr/lib/ext/product.rb
+++ b/plugins/solr/lib/ext/product.rb
@@ -19,7 +19,7 @@ class Product
     [:price, 0.35, proc{ |p| (!p.price.nil? and p.price > 0) ? 1 : 0}],
     [:new_product, 0.35, proc{ |p| (p.updated_at.to_i - p.created_at.to_i) < 24*3600 ? 1 : 0}],
     [:description, 0.3, proc{ |p| !p.description.blank? ? 1 : 0}],
-    [:enabled, 0.2, proc{ |p| p.enterprise.enabled ? 1 : 0}],
+    [:enabled, 0.2, proc{ |p| (p.enterprise and p.enterprise.enabled) ? 1 : 0}],
   ]
 
   acts_as_searchable :fields => facets_fields_for_solr + [
@@ -41,7 +41,7 @@ class Product
       {:qualifiers => {:fields => [:name]}},
       {:certifiers => {:fields => [:name]}},
     ], :facets => facets_option_for_solr,
-    :boost => proc{ |p| boost = 1; SolrPlugin::Boosts.each{ |b| boost = boost * (1 - ((1 - b[2].call(p)) * b[1])) }; boost}
+    :boost => proc{ |p| boost = 1; SolrPlugin::Boosts.each{ |b| boost = boost * (1 - ((1 - b[2].call(p)) * b[1])) } rescue nil; boost}
 
   handle_asynchronously :solr_save
   handle_asynchronously :solr_destroy



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b0da5a6aecd7a505074ed95930f1f274028caa99...b399a2bf3204bf57e35f8071fff970f39f109180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150617/30c99afb/attachment.html>


More information about the Noosfero-dev mailing list