Class: EVSS::DisabilityCompensationForm::SubmitUploads

Inherits:
Job
  • Object
show all
Defined in:
app/sidekiq/evss/disability_compensation_form/submit_uploads.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'worker.evss.submit_form526_upload'

Instance Method Summary collapse

Methods included from Sidekiq::Form526JobStatusTracker::JobTracker

#job_success, #job_try, #non_retryable_error_handler, #with_tracking

Methods included from Sidekiq::Form526JobStatusTracker::BackupSubmission

#send_backup_submission_if_enabled

Methods included from SentryLogging

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

Instance Method Details

#perform(submission_id, upload_data) ⇒ Object

Recursively submits a file in a new instance of this job for each upload in the uploads list

Parameters:

  • submission_id (Integer)
  • upload_data (String)

    upload GUID in AWS S3



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/sidekiq/evss/disability_compensation_form/submit_uploads.rb', line 61

def perform(submission_id, upload_data)
  Raven.tags_context(source: '526EZ-all-claims')
  super(submission_id)
  upload_data = upload_data.first if upload_data.is_a?(Array) # temporary for transition
  guid = upload_data&.dig('confirmationCode')
  with_tracking("Form526 Upload: #{guid}", submission.saved_claim_id, submission.id) do
    sea = SupportingEvidenceAttachment.find_by(guid:)
    file_body = sea&.get_file&.read

    raise ArgumentError, "supporting evidence attachment with guid #{guid} has no file data" if file_body.nil?

    document_data = create_document_data(upload_data, sea.converted_filename)
    raise Common::Exceptions::ValidationErrors, document_data unless document_data.valid?

    if Flipper.enabled?(:disability_compensation_lighthouse_document_service_provider)
      # TODO: create client from lighthouse document service
    else
      client = EVSS::DocumentsService.new(submission.auth_headers)
    end
    client.upload(file_body, document_data)
  end
rescue => e
  # Can't send a job manually to the dead set.
  # Log and re-raise so the job ends up in the dead set and the parent batch is not marked as complete.
  retryable_error_handler(e)
end