Class: Form1010cg::SubmissionJob

Inherits:
Object
  • Object
show all
Includes:
SentryLogging, Sidekiq::Job, Sidekiq::MonitoredWorker
Defined in:
app/sidekiq/form1010cg/submission_job.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
"#{Form1010cg::Auditor::STATSD_KEY_PREFIX}.async.".freeze
DD_ZSF_TAGS =
[
  'caregiver-application',
  'function: 10-10CG async form submission'
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

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

Class Method Details

.send_failure_email(parsed_form) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/sidekiq/form1010cg/submission_job.rb', line 61

def self.send_failure_email(parsed_form)
  first_name = parsed_form.dig('veteran', 'fullName', 'first')
  email = parsed_form.dig('veteran', 'email')
  template_id = Settings.vanotify.services.health_apps_1010.template_id.form1010_cg_failure_email
  api_key = Settings.vanotify.services.health_apps_1010.api_key
  salutation = first_name ? "Dear #{first_name}," : ''

  VANotify::EmailJob.perform_async(
    email,
    template_id,
    { 'salutation' => salutation },
    api_key
  )

  StatsD.increment("#{STATSD_KEY_PREFIX}submission_failure_email_sent")
end

Instance Method Details

#notify(params) ⇒ Object



34
35
36
37
38
39
40
# File 'app/sidekiq/form1010cg/submission_job.rb', line 34

def notify(params)
  # Add 1 to retry_count to match retry_monitoring logic
  retry_count = Integer(params['retry_count']) + 1

  StatsD.increment("#{STATSD_KEY_PREFIX}applications_retried") if retry_count == 1
  StatsD.increment("#{STATSD_KEY_PREFIX}failed_ten_retries", tags: ["params:#{params}"]) if retry_count == 10
end

#perform(claim_id) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/sidekiq/form1010cg/submission_job.rb', line 42

def perform(claim_id)
  claim = SavedClaim::CaregiversAssistanceClaim.find(claim_id)

  Form1010cg::Service.new(claim).process_claim_v2!

  begin
    claim.destroy!
  rescue => e
    log_exception_to_sentry(e)
  end
rescue CARMA::Client::MuleSoftClient::RecordParseError
  StatsD.increment("#{STATSD_KEY_PREFIX}record_parse_error", tags: ["claim_id:#{claim_id}"])
rescue => e
  log_exception_to_sentry(e)
  StatsD.increment("#{STATSD_KEY_PREFIX}retries")

  raise
end

#retry_limits_for_notificationObject



30
31
32
# File 'app/sidekiq/form1010cg/submission_job.rb', line 30

def retry_limits_for_notification
  [1, 10]
end