<commit_before># encoding: utf-8

class NoisyWorkflow < ActionMailer::Base
  default :from => "Winston (GOV.UK Publisher) <<EMAIL>>"

  def make_noise(action)
    @action = action

    if action.edition.business_proposition
      subject = "[PUBLISHER]-BUSINESS #{describe_action(@action)}"
      recipient_emails = EMAIL_GROUPS[:business]
    else
      subject = "[PUBLISHER] #{describe_action(@action)}"
      recipient_emails = EMAIL_GROUPS[:citizen]
    end

    mail(:to => recipient_emails.join(', '), :subject => subject)
  end

  def request_fact_check(action)
    @edition = action.edition
    fact_check_address = @edition.fact_check_email_address
    mail(:to => action.email_addresses, :reply_to => fact_check_address,
      :from => "Beta Editorial Team <#{fact_check_address}>",
      :subject => "[FACT CHECK REQUESTED] #{@edition.title}") do |format|
     format.text { render :text => action.customised_message }
    end
  end

  def report_errors(error_list)
    @errors = error_list
    mail(:to => EMAIL_GROUPS[:dev], :subject => 'Errors in fact check email processing')
  end

  protected
  def describe_action(action)
    edition = action.edition
    requester = action.requester
    recipient = action.recipient

    case action.request_type
    when Action::CREATE
      "Created #{edition.format_name}: \"#{edition.title}\" (by #{requester.name})"<commit_msg>Update Fact Check Email 'From' Name<commit_after># encoding: utf-8

class NoisyWorkflow < ActionMailer::Base
  default :from => "Winston (GOV.UK Publisher) <<EMAIL>>"

  def make_noise(action)
    @action = action

    if action.edition.business_proposition
      subject = "[PUBLISHER]-BUSINESS #{describe_action(@action)}"
      recipient_emails = EMAIL_GROUPS[:business]
    else
      subject = "[PUBLISHER] #{describe_action(@action)}"
      recipient_emails = EMAIL_GROUPS[:citizen]
    end

    mail(:to => recipient_emails.join(', '), :subject => subject)
  end

  def request_fact_check(action)
    @edition = action.edition
    fact_check_address = @edition.fact_check_email_address
    mail(:to => action.email_addresses, :reply_to => fact_check_address,
      :from => "GOV.UK Editorial Team <#{fact_check_address}>",
      :subject => "[FACT CHECK REQUESTED] #{@edition.title}") do |format|
     format.text { render :text => action.customised_message }
    end
  end

  def report_errors(error_list)
    @errors = error_list
    mail(:to => EMAIL_GROUPS[:dev], :subject => 'Errors in fact check email processing')
  end

  protected
  def describe_action(action)
    edition = action.edition
    requester = action.requester
    recipient = action.recipient

    case action.request_type
    when Action::CREATE
      "Created #{edition.format_name}: \"#{edition.title}\" (by #{requester.name})"
{'fraction_non_alphanumeric': 0.12562634216177523, 'fraction_numerical': 0.0007158196134574087, 'mean_word_length': 3.982174688057041, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '4124913', 'n_tokens_mistral': 909, 'n_tokens_neox': 897, 'n_words': 194}