<commit_before>class VirtualWorkshopInvitationMailer < ActionMailer::Base
  include EmailHelper
  include EmailHeaderHelper
  include ApplicationHelper

  helper ApplicationHelper
  helper EmailHelper

  def attending(workshop, member, invitation, waiting_list = false)
    @workshop = VirtualWorkshopPresenter.new(workshop)
    @member = member
    @invitation = invitation
    @waiting_list = waiting_list

    subject = "Attendance Confirmation: #{I18n.t('workshop.virtual.title',
                                                 chapter: @workshop.chapter.name,
                                                 date: humanize_date(@workshop.date_and_time))}"

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end

  def attending_reminder(workshop, member, invitation)
    subject = t('mailer.workshop_invitation.virtual.attending_reminder.subject',
                date_time: humanize_date(workshop.date_and_time, with_time: true))

    @workshop = workshop
    @member = member
    @invitation = invitation

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end

  def invite_coach(workshop, member, invitation)
    @workshop = workshop
    @member = member
    @invitation = invitation

    subject = t('mailer.workshop_invitation.virtual.invite_coach.subject',
                date_time: humanize_date(@workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, '<EMAIL>'), &:html)
  end

  def invite_student(workshop, member, invitation)
    @workshop = VirtualWorkshopPresenter.new(workshop)
    @member = member
    @invitation = invitation

    subject = t('mailer.workshop_invitation.virtual.invite_student.subject',
                date_time: humanize_date(@workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, '<EMAIL>'), &:html)
  end

  def waiting_list_reminder(workshop, member, invitation)
    subject = t('mailer.workshop_invitation.waiting_list_reminder.subject',
                date_time: humanize_date(workshop.date_and_time, with_time: true))
    @workshop = workshop
    @member = member
    @invitation = invitation

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end
end<commit_msg>(refactoring) extract common mailer method code to `setup` method<commit_after>class VirtualWorkshopInvitationMailer < ActionMailer::Base
  include EmailHelper
  include EmailHeaderHelper
  include ApplicationHelper

  helper ApplicationHelper
  helper EmailHelper

  def attending(workshop, member, invitation, waiting_list = false)
    setup(workshop, invitation, member)
    @waiting_list = waiting_list

    subject = "Attendance Confirmation: #{I18n.t('workshop.virtual.title',
                                                 chapter: @workshop.chapter.name,
                                                 date: humanize_date(@workshop.date_and_time))}"

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end

  def attending_reminder(workshop, member, invitation)
    setup(workshop, invitation, member)
    subject = t('mailer.workshop_invitation.virtual.attending_reminder.subject',
                date_time: humanize_date(workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end

  def invite_coach(workshop, member, invitation)
    setup(workshop, invitation, member)
    subject = t('mailer.workshop_invitation.virtual.invite_coach.subject',
                date_time: humanize_date(@workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, '<EMAIL>'), &:html)
  end

  def invite_student(workshop, member, invitation)
    setup(workshop, invitation, member)
    subject = t('mailer.workshop_invitation.virtual.invite_student.subject',
                date_time: humanize_date(@workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, '<EMAIL>'), &:html)
  end

  def waiting_list_reminder(workshop, member, invitation)
    setup(workshop, invitation, member)
    subject = t('mailer.workshop_invitation.waiting_list_reminder.subject',
                date_time: humanize_date(workshop.date_and_time, with_time: true))

    mail(mail_args(member, subject, @workshop.chapter.email), &:html)
  end

  private

  def setup(workshop, invitation, member)
    @workshop = workshop
    @member = member
    @invitation = invitation
  end
end
{'fraction_non_alphanumeric': 0.0985244040862656, 'fraction_numerical': 0.0009080590238365494, 'mean_word_length': 3.633017875920084, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2973378', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1289, 'n_words': 254}