-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into arf.92364/clarify-gclaws-vets-api-next-steps
* master: case9 logic fixed (#18362) API-39748-add-index-to-error-collection-messages (#18333) Use random value in Simple Forms PDF stamping file paths (#18361) Add `find_dependents_by_ptcpnt_id` to local bgs (#18303) remove request_ping defs (#18353) API-38827-update-validations-intl-postal-code (#18323) [Document Upload Failure] Email veteran on Form 0781/Form 0781a upload retry exhaustion (#18206) add feature flags for meb and 5490 (#18328) Handle 500 responses from VA Profile v3 Service for v0/profile/contacts endpoint (#18192) Resolve MethodLength Rubocop Disables - Part 3 (#18331) Resolve MethodLength Rubocop Disables - Part BGS::Form674 (#18326)
- Loading branch information
Showing
31 changed files
with
673 additions
and
254 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
app/sidekiq/evss/disability_compensation_form/form0781_document_upload_failure_email.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'va_notify/service' | ||
|
||
module EVSS | ||
module DisabilityCompensationForm | ||
class Form0781DocumentUploadFailureEmail < Job | ||
STATSD_METRIC_PREFIX = 'api.form_526.veteran_notifications.form0781_upload_failure_email' | ||
|
||
# retry for one day | ||
sidekiq_options retry: 14 | ||
|
||
sidekiq_retries_exhausted do |msg, _ex| | ||
job_id = msg['jid'] | ||
error_class = msg['error_class'] | ||
error_message = msg['error_message'] | ||
timestamp = Time.now.utc | ||
form526_submission_id = msg['args'].first | ||
|
||
# Job status records are upserted in the JobTracker module | ||
# when the retryable_error_handler is called | ||
form_job_status = Form526JobStatus.find_by(job_id:) | ||
bgjob_errors = form_job_status.bgjob_errors || {} | ||
new_error = { | ||
"#{timestamp.to_i}": { | ||
caller_method: __method__.to_s, | ||
timestamp:, | ||
form526_submission_id: | ||
} | ||
} | ||
form_job_status.update( | ||
status: Form526JobStatus::STATUS[:exhausted], | ||
bgjob_errors: bgjob_errors.merge(new_error) | ||
) | ||
|
||
Rails.logger.warn( | ||
'Form0781DocumentUploadFailureEmail retries exhausted', | ||
{ | ||
job_id:, | ||
timestamp:, | ||
form526_submission_id:, | ||
error_class:, | ||
error_message: | ||
} | ||
) | ||
|
||
StatsD.increment("#{STATSD_METRIC_PREFIX}.exhausted") | ||
rescue => e | ||
Rails.logger.error( | ||
'Failure in Form0781DocumentUploadFailureEmail#sidekiq_retries_exhausted', | ||
{ | ||
job_id:, | ||
messaged_content: e.message, | ||
submission_id: form526_submission_id, | ||
pre_exhaustion_failure: { | ||
error_class:, | ||
error_message: | ||
} | ||
} | ||
) | ||
raise e | ||
end | ||
|
||
def perform(form526_submission_id) | ||
form526_submission = Form526Submission.find(form526_submission_id) | ||
|
||
with_tracking('Form0781DocumentUploadFailureEmail', form526_submission.saved_claim_id, form526_submission_id) do | ||
notify_client = VaNotify::Service.new(Settings.vanotify.services.benefits_disability.api_key) | ||
|
||
email_address = form526_submission.veteran_email_address | ||
first_name = form526_submission.get_first_name | ||
date_submitted = form526_submission.format_creation_time_for_mailers | ||
|
||
notify_client.send_email( | ||
email_address:, | ||
template_id: mailer_template_id, | ||
personalisation: { | ||
first_name:, | ||
date_submitted: | ||
} | ||
) | ||
|
||
StatsD.increment("#{STATSD_METRIC_PREFIX}.success") | ||
end | ||
rescue => e | ||
retryable_error_handler(e) | ||
end | ||
|
||
private | ||
|
||
def retryable_error_handler(error) | ||
# Needed to log the error properly in the Sidekiq::Form526JobStatusTracker::JobTracker, | ||
# which is included near the top of this job's inheritance tree in EVSS::DisabilityCompensationForm::JobStatus | ||
super(error) | ||
raise error | ||
end | ||
|
||
def mailer_template_id | ||
Settings.vanotify.services | ||
.benefits_disability.template_id.form0781_upload_failure_notification_template_id | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.