Module: Sidekiq::Form526JobStatusTracker::BackupSubmission

Included in:
JobTracker
Defined in:
lib/sidekiq/form526_job_status_tracker/backup_submission.rb

Instance Method Summary collapse

Instance Method Details

#send_backup_submission_if_enabled(form526_submission_id:, job_class:, job_id:, error_class:, error_message:) ⇒ Object

rubocop:disable Metrics/MethodLength



7
8
9
10
11
12
13
14
15
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
42
43
44
# File 'lib/sidekiq/form526_job_status_tracker/backup_submission.rb', line 7

def send_backup_submission_if_enabled(form526_submission_id:, job_class:, job_id:, error_class:,
                                      error_message:)
  submission_obj = Form526Submission.find(form526_submission_id)
  if Flipper.enabled?(:disability_compensation_production_tester,
                      OpenStruct.new({ flipper_id: submission_obj.user_uuid }))
    ::Rails.logger.info("send_backup_submission_if_enabled call skipped for submission #{form526_submission_id}")
    return
  end

  backup_job_jid = nil
  flipper_sym = :form526_backup_submission_temp_killswitch
  # Entry-point for backup 526 CMP submission
  #
  # Required criteria to send a backup 526 submission from here:
  # Enabled in settings and flipper
  # Is an overall submission and NOT an upload attempt
  # Does not have a valid claim ID (through RRD process or otherwise) (protect against dup submissions)
  # Does not have a backup submission ID (protect against dup submissions)
  # Does not have a submission ID (protect against dup submissions)
  # Does not have additional birls it is going to try and submit with
  send_backup_submission = Settings.form526_backup.enabled && Flipper.enabled?(flipper_sym) &&
                           job_class == 'SubmitForm526AllClaim' &&
                           submission_obj..nil? &&
                           (additional_birls = submission_obj.birls_ids_that_havent_been_tried_yet).empty? &&
                           submission_obj..nil? &&
                           submission_obj..nil?

  if send_backup_submission
    backup_job_jid = Sidekiq::Form526BackupSubmissionProcess::Submit.perform_async(form526_submission_id)
  end
  vagov_id = JSON.parse(submission_obj.auth_headers_json)['va_eauth_service_transaction_id']
  log_message = {
    submission_id: form526_submission_id, job_id:, job_class:, error_class:, error_message:,
    remaining_birls: additional_birls, va_eauth_service_transaction_id: vagov_id
  }
  log_message['backup_job_id'] = backup_job_jid unless backup_job_jid.nil?
  ::Rails.logger.error('Form526 Exhausted or Errored (retryable-error-path)', log_message)
end