<commit_before>Spree::OrderMailer.class_eval do
  helper HtmlHelper
  helper CheckoutHelper
  helper SpreeCurrencyHelper

  def cancel_email(order, resend = false)
    @order = find_order(order)
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
    mail(to: order.email, from: from_address, subject: subject)
  end

  def confirm_email_for_customer(order, resend = false)
    find_order(order) # Finds an order instance from an id
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
    mail(:to => @order.email,
         :from => from_address,
         :subject => subject,
         :reply_to => @order.distributor.email)
  end

  def confirm_email_for_shop(order, resend = false)
    find_order(order) # Finds an order instance from an id
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
    mail(:to => @order.distributor.email,
         :from => from_address,
         :subject => subject)
  end

  def invoice_email(order, pdf)
    find_order(order) # Finds an order instance from an id
    attachments["invoice-#{@order.number}.pdf"] = pdf if pdf.present?
    subject = "#{Spree::Config[:site_name]} #{t(:invoice)} ##{@order.number}"
    mail(:to => @order.email,
         :from => from_address,
         :subject => subject,
         :reply_to => @order.distributor.email)
  end

  def find_order(order)
    order.respond_to?(:id) ? order : Spree::Order.find(order)
  end
end<commit_msg>Fix OrderMailer#find_order<commit_after>Spree::OrderMailer.class_eval do
  helper HtmlHelper
  helper CheckoutHelper
  helper SpreeCurrencyHelper

  def cancel_email(order, resend = false)
    @order = find_order(order)
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.cancel_email.subject')} ##{order.number}"
    mail(to: order.email, from: from_address, subject: subject)
  end

  def confirm_email_for_customer(order, resend = false)
    find_order(order) # Finds an order instance from an id
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
    mail(:to => @order.email,
         :from => from_address,
         :subject => subject,
         :reply_to => @order.distributor.email)
  end

  def confirm_email_for_shop(order, resend = false)
    find_order(order) # Finds an order instance from an id
    subject = (resend ? "[#{t(:resend).upcase}] " : '')
    subject += "#{Spree::Config[:site_name]} #{t('order_mailer.confirm_email.subject')} ##{@order.number}"
    mail(:to => @order.distributor.email,
         :from => from_address,
         :subject => subject)
  end

  def invoice_email(order, pdf)
    find_order(order) # Finds an order instance from an id
    attachments["invoice-#{@order.number}.pdf"] = pdf if pdf.present?
    subject = "#{Spree::Config[:site_name]} #{t(:invoice)} ##{@order.number}"
    mail(:to => @order.email,
         :from => from_address,
         :subject => subject,
         :reply_to => @order.distributor.email)
  end

  def find_order(order)
    @order = order.respond_to?(:id) ? order : Spree::Order.find(order)
  end
end
{'fraction_non_alphanumeric': 0.16570936243538195, 'fraction_numerical': 0.0, 'mean_word_length': 3.8645251396648046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '2129047', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1156, 'n_words': 235}