mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Doc what with_lock does
This commit is contained in:
committed by
Rob Harrington
parent
1faa1579f3
commit
a763c24f3c
@@ -16,6 +16,10 @@ module Admin
|
||||
load_line_item
|
||||
authorize_update!
|
||||
|
||||
# `with_lock` acquires an exclusive row lock on order so no other
|
||||
# requests can update it until the transaction is commited.
|
||||
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
|
||||
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
|
||||
order.with_lock do
|
||||
if @line_item.update_attributes(params[:line_item])
|
||||
order.update_distribution_charge!
|
||||
|
||||
@@ -181,6 +181,10 @@ Spree::Order.class_eval do
|
||||
end
|
||||
|
||||
def update_distribution_charge!
|
||||
# `with_lock` acquires an exclusive row lock on order so no other
|
||||
# requests can update it until the transaction is commited.
|
||||
# See https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/locking/pessimistic.rb#L69
|
||||
# and https://www.postgresql.org/docs/current/static/sql-select.html#SQL-FOR-UPDATE-SHARE
|
||||
with_lock do
|
||||
EnterpriseFee.clear_all_adjustments_on_order self
|
||||
|
||||
|
||||
Reference in New Issue
Block a user