<commit_before>Spree::Api::LineItemsController.class_eval do
  after_filter :apply_enterprise_fees, only: :update


  private

  def apply_enterprise_fees
    authorize! :read, order
    order.update_distribution_charge!
  end
end<commit_msg>Locking line_items on API update<commit_after>Spree::Api::LineItemsController.class_eval do
  after_filter :apply_enterprise_fees, only: :update
  around_filter :lock, only: :update

  private

  def lock
    authorize! :read, order
    @line_item = order.line_items.find(params[:id])
    @line_item.with_lock do
      yield
    end
  end

  def apply_enterprise_fees
    authorize! :read, order
    order.update_distribution_charge!
  end
end
{'fraction_non_alphanumeric': 0.07591240875912408, 'fraction_numerical': 0.0, 'mean_word_length': 4.5772357723577235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '372235', 'n_tokens_mistral': 232, 'n_tokens_neox': 223, 'n_words': 49}