Class: Lighthouse::SubmitCareerCounselingJob

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/sidekiq/lighthouse/submit_career_counseling_job.rb

Constant Summary collapse

RETRY =
16
STATSD_KEY_PREFIX =
'worker.lighthouse.submit_career_counseling_job'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.trigger_failure_events(msg, claim) ⇒ Object



60
61
62
63
64
65
# File 'app/sidekiq/lighthouse/submit_career_counseling_job.rb', line 60

def self.trigger_failure_events(msg, claim)
  pcpg_monitor = PCPG::Monitor.new
  email = claim.parsed_form.dig('claimantInformation', 'emailAddress')
  pcpg_monitor.track_submission_exhaustion(msg, claim, email)
  claim.send_failure_email(email) if claim.present?
end

Instance Method Details

#perform(claim_id, user_uuid = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'app/sidekiq/lighthouse/submit_career_counseling_job.rb', line 26

def perform(claim_id, user_uuid = nil)
  begin
    @claim = SavedClaim.find(claim_id)
    @claim.send_to_benefits_intake!
    send_confirmation_email(user_uuid)
  rescue => e
    Rails.logger.warn('SubmitCareerCounselingJob failed, retrying...', { error_message: e.message })
    raise
  end
  Rails.logger.info('Successfully submitted form 25-8832', { uuid: user_uuid })
end

#send_confirmation_email(user_uuid) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/sidekiq/lighthouse/submit_career_counseling_job.rb', line 38

def send_confirmation_email(user_uuid)
  email = if user_uuid.present? && (found_email = User.find(user_uuid)&.va_profile_email)
            found_email
          else
            @claim.parsed_form.dig('claimantInformation', 'emailAddress')
          end

  if email.blank?
    Rails.logger.info("No email to send confirmation regarding submitted form 25-8832 for uuid: #{user_uuid}")
    return
  end

  VANotify::EmailJob.perform_async(
    email,
    Settings.vanotify.services.va_gov.template_id.career_counseling_confirmation_email,
    {
      'first_name' => @claim.parsed_form.dig('claimantInformation', 'fullName', 'first')&.upcase.presence,
      'date' => Time.zone.today.strftime('%B %d, %Y')
    }
  )
end