<commit_before>class TeamBuildingMailer < BaseMailer
  layout false

  def success(product_id)
    mailgun_campaign 'notifications'

    @product = Product.find(product_id)
    @application = PitchWeekApplication.where(product_id: @product.id).
      order('created_at DESC').
      first
    @user = @application.applicant || @product.core_team.order('created_at DESC').first

    mail to: @user.email_address,
      from: '<EMAIL>',
      subject: "Yay! You did it. #{@product.name} was just greenlit."
  end

  def failure(product_id)
    mailgun_campaign 'notifications'

    @product = Product.find(product_id)
    @application = PitchWeekApplication.where(product_id: @product.id).
      order('created_at DESC').
      first
    @user = @application.applicant || @product.core_team.order('created_at DESC').first

    mail to: @user.email_address,
      from: '<EMAIL>',
      subject: "Bummer. #{@product.name} didn't meet its team building goal."
  end
end<commit_msg>Oops. Make sure we check the application first<commit_after>class TeamBuildingMailer < BaseMailer
  layout false

  def success(product_id)
    mailgun_campaign 'notifications'

    @product = Product.find(product_id)
    @application = PitchWeekApplication.where(product_id: @product.id).
      order('created_at DESC').
      first
    @user = @application && @application.applicant || @product.core_team.order('created_at DESC').first

    mail to: @user.email_address,
      from: '<EMAIL>',
      subject: "Yay! You did it. #{@product.name} was just greenlit."
  end

  def failure(product_id)
    mailgun_campaign 'notifications'

    @product = Product.find(product_id)
    @application = PitchWeekApplication.where(product_id: @product.id).
      order('created_at DESC').
      first
    @user = @application && @application.applicant || @product.core_team.order('created_at DESC').first

    mail to: @user.email_address,
      from: '<EMAIL>',
      subject: "Bummer. #{@product.name} didn't meet its team building goal."
  end
end
{'fraction_non_alphanumeric': 0.12233779098563645, 'fraction_numerical': 0.0, 'mean_word_length': 3.7529411764705882, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5306206', 'n_tokens_mistral': 642, 'n_tokens_neox': 621, 'n_words': 144}