<commit_before>class ProducerMailer < Spree::BaseMailer

  def order_cycle_report(producer, order_cycle)
    @producer = producer
    @coordinator = order_cycle.coordinator
    @order_cycle = order_cycle
    line_items = line_items_from(@order_cycle, @producer)
    @grouped_line_items = line_items.group_by(&:product_and_full_name)
    @receival_instructions = @order_cycle.receival_instructions_for @producer
    @total = total_from_line_items(line_items)
    @tax_total = tax_total_from_line_items(line_items)

    subject = "[#{Spree::Config.site_name}] Order cycle report for #{producer.name}"

    if has_orders? order_cycle, producer
      mail(to: @producer.email,
           from: from_address,
           subject: subject,
           reply_to: @coordinator.email,
           cc: @coordinator.email)
    end
  end


  private

  def has_orders?(order_cycle, producer)
    line_items_from(order_cycle, producer).any?
  end

  def line_items_from(order_cycle, producer)
    Spree::LineItem.
      joins(:order => :order_cycle, :variant => :product).
      where('order_cycles.id = ?', order_cycle).
      merge(Spree::Product.in_supplier(producer)).
      merge(Spree::Order.complete)
  end

  def total_from_line_items(line_items)
    Spree::Money.new line_items.sum(&:total)
  end

  def tax_total_from_line_items(line_items)
    Spree::Money.new line_items.sum(&:included_tax)
  end
end<commit_msg>Update from address in notification emails<commit_after>class ProducerMailer < Spree::BaseMailer

  def order_cycle_report(producer, order_cycle)
    @producer = producer
    @coordinator = order_cycle.coordinator
    @order_cycle = order_cycle
    line_items = line_items_from(@order_cycle, @producer)
    @grouped_line_items = line_items.group_by(&:product_and_full_name)
    @receival_instructions = @order_cycle.receival_instructions_for @producer
    @total = total_from_line_items(line_items)
    @tax_total = tax_total_from_line_items(line_items)

    subject = "[#{Spree::Config.site_name}] Order cycle report for #{producer.name}"

    if has_orders? order_cycle, producer
      mail(to: @producer.email,
           from: @coordinator.email,
           subject: subject,
           reply_to: @coordinator.email,
           cc: @coordinator.email)
    end
  end


  private

  def has_orders?(order_cycle, producer)
    line_items_from(order_cycle, producer).any?
  end

  def line_items_from(order_cycle, producer)
    Spree::LineItem.
      joins(:order => :order_cycle, :variant => :product).
      where('order_cycles.id = ?', order_cycle).
      merge(Spree::Product.in_supplier(producer)).
      merge(Spree::Order.complete)
  end

  def total_from_line_items(line_items)
    Spree::Money.new line_items.sum(&:total)
  end

  def tax_total_from_line_items(line_items)
    Spree::Money.new line_items.sum(&:included_tax)
  end
end
{'fraction_non_alphanumeric': 0.10242020343739039, 'fraction_numerical': 0.0, 'mean_word_length': 4.101967799642218, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '751777', 'n_tokens_mistral': 966, 'n_tokens_neox': 943, 'n_words': 160}