Fixed strange RecordReadOnly exception in task done.
This commit is contained in:
parent
cabcd201a6
commit
0fcd5abb3a
2 changed files with 2 additions and 1 deletions
|
@ -62,6 +62,7 @@ class Ordergroup < Group
|
|||
# Get group_order.price for every finished order in this period
|
||||
orders_sum = group_orders.includes(:order).merge(Order.finished).where('orders.ends >= ?', time).sum(:price)
|
||||
|
||||
@readonly = false # Dirty hack, avoid getting RecordReadOnly exception when called in task after_save callback. A rails bug?
|
||||
update_attribute(:stats, {:jobs_size => jobs, :orders_sum => orders_sum})
|
||||
end
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class Task < ActiveRecord::Base
|
|||
|
||||
def update_ordergroup_stats
|
||||
if done
|
||||
users.each { |u| u.ordergroup.update_stats! if u.ordergroup }
|
||||
Ordergroup.joins(:users).where(users: {id: user_ids}).each(&:update_stats!)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue