<commit_before>Spree::Shipment.class_eval do
  has_many :fulfillments

  def fulfillment_provider
    shipping_method.calculator.respond_to?(:fulfillment_provider) ? shipping_method.calculator.fulfillment_provider : nil
  end

  def fulfillment_service
    shipping_method.calculator.service
  end

  def refresh_fulfillments(not_refreshed_for=0)
    fulfillments_to_refresh(not_refreshed_for).each do |fulfillment|
      fulfillment_provider.refresh_fulfillment(fulfillment)
    end
  end

  alias_method :orig_finalize!, :finalize!
  def finalize!
    orig_finalize!
    if fulfillment_provider
      fulfillment_provider.fulfill(self, fulfillment_service)
    end
  end

  alias_method :orig_after_cancel, :after_cancel
  def after_cancel
    orig_after_cancel
    fulfillments.each(&:cancel)<commit_msg>Only fulfill orders immediately if they are safe<commit_after>Spree::Shipment.class_eval do
  has_many :fulfillments

  def fulfillment_provider
    shipping_method.calculator.respond_to?(:fulfillment_provider) ? shipping_method.calculator.fulfillment_provider : nil
  end

  def fulfillment_service
    shipping_method.calculator.service
  end

  def refresh_fulfillments(not_refreshed_for=0)
    fulfillments_to_refresh(not_refreshed_for).each do |fulfillment|
      fulfillment_provider.refresh_fulfillment(fulfillment)
    end
  end

  alias_method :orig_finalize!, :finalize!
  def finalize!
    orig_finalize!
    if fulfillment_provider && !order.is_risky?
      ship
    end
  end

  alias_method :orig_after_ship, :after_ship
  def after_ship
    orig_after_ship
    if fulfillment_provider
      fulfillment_provider.fulfill(self, fulfillment_service)
    end
  end

  alias_method :orig_after_cancel, :after_cancel
  def after_cancel
    orig_after_cancel
    fulfillments.each(&:cancel)
{'fraction_non_alphanumeric': 0.058725761772853186, 'fraction_numerical': 0.00110803324099723, 'mean_word_length': 4.8827361563517915, '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': '7573821', 'n_tokens_mistral': 592, 'n_tokens_neox': 575, 'n_words': 100}