Skip to content

Commit

Permalink
[DBX-74810] Add flipper with LH BI api for 4142
Browse files Browse the repository at this point in the history
  • Loading branch information
SamStuckey committed Apr 24, 2024
1 parent 6af92d9 commit de76850
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
38 changes: 27 additions & 11 deletions app/sidekiq/central_mail/submit_form4142_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,10 @@ class SubmitForm4142Job < EVSS::DisabilityCompensationForm::Job
}
)

STATSD_KEY_PREFIX = 'worker.evss.submit_form4142'
CENTRAL_MAIL_STATSD_KEY_PREFIX = 'worker.evss.submit_form4142'
LIGHTHOUSE_STATSD_KEY_PREFIX = 'worker.lighthouse.submit_form4142'

# Sidekiq has built in exponential back-off functionality for retries
# A max retry attempt of 10 will result in a run time of ~8 hours
# This job is invoked from 526 background job, ICMHS is reliable
# and hence this value is set at a lower value
RETRY = 10

sidekiq_options retry: RETRY

class CentralMailResponseError < Common::Exceptions::BackendServiceException; end
class BenefitsIntake4142Error < StandardError; end

sidekiq_retries_exhausted do |msg, _ex|
job_id = msg['jid']
Expand All @@ -51,6 +44,7 @@ class CentralMailResponseError < Common::Exceptions::BackendServiceException; en
form526_submission_id:
}
}
# [wipn8923] update use of statsD keys
form_job_status.update(
status: Form526JobStatus::STATUS[:exhausted],
bgjob_errors: bgjob_errors.merge(new_error)
Expand Down Expand Up @@ -82,6 +76,7 @@ class CentralMailResponseError < Common::Exceptions::BackendServiceException; en
#
# @param submission_id [Integer] the {Form526Submission} id
#
# [wipn8923] job to update?
def perform(submission_id)
@submission_id = submission_id

Expand All @@ -90,7 +85,7 @@ def perform(submission_id)

with_tracking('Form4142 Submission', submission.saved_claim_id, submission.id) do
@pdf_path = processor.pdf_path
response = upload_to_central_mail
response = upload_to_api
handle_service_exception(response) if response.present? && response.status.between?(201, 600)
end
rescue => e
Expand All @@ -109,10 +104,31 @@ def processor
@processor ||= EVSS::DisabilityCompensationForm::Form4142Processor.new(submission, jid)
end

def upload_to_api
if Flipper.enabled?(:disability_compensation_form_4142)

Check failure on line 108 in app/sidekiq/central_mail/submit_form4142_job.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Naming/VariableNumber: Use normalcase for symbol numbers.
upload_to_lighthouse
else
upload_to_central_mail
end
end

def upload_to_central_mail
CentralMail::Service.new.upload(processor.request_body)
end

def upload_to_lighthouse
@lighthouse_service = BenefitsIntakeService::Service.new(with_upload_location: true)
payload = {

Check failure on line 121 in app/sidekiq/central_mail/submit_form4142_job.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Lint/UselessAssignment: Useless assignment to variable - `payload`. Did you mean `paylod`?
upload_url: @lighthouse_service.location,
file: { file: @pdf_path, file_name: @pdf_path.split('/').last },
metadata: generate_metadata.to_json,
attachments: [] # wipn8923 is this better than nil?
}
create_form_submission_attempt

@lighthouse_service.upload_doc(**paylod)
end

# Cannot move job straight to dead queue dynamically within an executing job
# raising error for all the exceptions as sidekiq will then move into dead queue
# after all retries are exhausted
Expand Down
1 change: 1 addition & 0 deletions app/sidekiq/lighthouse/submit_benefits_intake_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require 'pdf_info'

module Lighthouse
# [wipn8923] API template
class SubmitBenefitsIntakeClaim
include Sidekiq::Job
include SentryLogging
Expand Down
1 change: 1 addition & 0 deletions lib/decision_review_v1/utilities/form_4142_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

module DecisionReviewV1
module Processor
# [wipn8923] why is this being used in the backup path?
class Form4142Processor
# @return [Pathname] the generated PDF path
attr_reader :pdf_path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module DisabilityCompensationForm
# A {Form4142Processor} handles the work of generating a stamped PDF
# and a request body for a 4142 CentralMail submission
#
# [wipn8923] seems to be the processor I want
class Form4142Processor
# @return [Pathname] the generated PDF path
attr_reader :pdf_path
Expand Down

0 comments on commit de76850

Please sign in to comment.