Small improvement for update price. Removed delayed job.

Attention, every delayed job has to know its Foodcoop scope. Otherwise
every task will be executed in the default database. See email delivery.
This commit is contained in:
benni 2012-12-16 21:46:24 +01:00
parent 0dff5ea784
commit 1298af8377
3 changed files with 3 additions and 4 deletions

View file

@ -76,7 +76,7 @@ class GroupOrder < ActiveRecord::Base
# Updates the "price" attribute.
def update_price!
total = group_order_articles.includes(:order_article => :article).all.map(&:total_price).sum
total = group_order_articles.includes(:order_article => [:article, :article_price]).to_a.sum(&:total_price)
update_attribute(:price, total)
end

View file

@ -164,10 +164,10 @@ class Order < ActiveRecord::Base
end
# Update GroupOrder prices
group_orders.each { |go| go.update_price! }
group_orders.each(&:update_price!)
# Stats
ordergroups.each { |o| o.update_stats! }
ordergroups.each(&:update_stats!)
# Notifications
UserNotifier.delay.finished_order(self.id)

View file

@ -137,7 +137,6 @@ class OrderArticle < ActiveRecord::Base
def update_ordergroup_prices
group_order_articles.each { |goa| goa.group_order.update_price! }
end
handle_asynchronously :update_ordergroup_prices
end