Class: EducationForm::Create10203ApplicantDecisionLetters

Inherits:
Object
  • Object
show all
Includes:
SentryLogging, Sidekiq::Job
Defined in:
app/sidekiq/education_form/create10203_applicant_decision_letters.rb

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#perform(records: EducationBenefitsClaim.includes(:saved_claim, :education_stem_automated_decision).where( saved_claims: { form_id: '22-10203' }, education_stem_automated_decisions: { automated_decision_state: EducationStemAutomatedDecision::DENIED, denial_email_sent_at: nil } )) ⇒ Object

Get all 10203 submissions that have a row in education_stem_automated_decisions



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/sidekiq/education_form/create10203_applicant_decision_letters.rb', line 16

def perform(
  records: EducationBenefitsClaim.includes(:saved_claim, :education_stem_automated_decision).where(
    saved_claims: {
      form_id: '22-10203'
    },
    education_stem_automated_decisions: {
      automated_decision_state: EducationStemAutomatedDecision::DENIED,
      denial_email_sent_at: nil
    }
  )
)
  if records.count.zero?
    log_info('No records to process.')
    return true
  else
    log_info("Processing #{records.count} denied application(s)")
  end

  records.each do |record|
    StemApplicantDenialMailer.build(record, nil).deliver_now
    record.education_stem_automated_decision.update(denial_email_sent_at: Time.zone.now)
  rescue => e
    inform_on_error(record, e)
  end
  true
end