-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial 526 form 4142 benefits intake API work #18801
Open
kylesoskin
wants to merge
74
commits into
master
Choose a base branch
from
dbex/94144_trigger_email_on_polled_4142_failure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+216
−47
Open
Changes from all commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
98b5b0d
Initial 526 form 4142 benefits intake API work
kylesoskin 60e5bd2
Specing out more
kylesoskin 4c68bf8
Rubocop'ing
kylesoskin a9e2bf2
Renaming to more generic 4142 class
kylesoskin e2829ef
Moving around
kylesoskin 5b28b45
Moving
kylesoskin eacb120
adding some testing they are faling due to error with VCR/filenumber …
kylesoskin b08f2f7
rubocop
kylesoskin 6acea92
Adding additional testing
kylesoskin 165d4a6
Remove debug
kylesoskin 67c19f1
model tests
kylesoskin 9e530c1
More tests
kylesoskin f6ae257
Rubocop and email and flipper support
kylesoskin a871cab
Dont need to add to my change linecount
kylesoskin 793a68d
Remove whitespace
kylesoskin d88fc3d
Removing my own model, using existing FormSubmission/Form526Submission
kylesoskin 5955c9b
altering tests
kylesoskin 397b1e8
Rubocop
kylesoskin 577fbe7
Rubocopin
kylesoskin bdc1195
Changing to pass
kylesoskin 45e0d62
Undoing db changes no longer needed
kylesoskin e9114e9
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 8289238
unresolved merge fixes
kylesoskin 86a35ee
Removing benefits intake service class to another PR
kylesoskin 80cf011
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 8d95332
rubocoping
kylesoskin 1b4e5d5
Not sure where this came from but undoing it
kylesoskin 6d14811
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin e71224a
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin df3fb23
Fixing location of bool
kylesoskin 0e5ab0d
Merge branch 'dbex/94144_trigger_email_on_polled_4142_failure' of htt…
kylesoskin ddf05d0
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 19888ee
Rubocop
kylesoskin b56dc01
Adding test case for flippers off
kylesoskin 23c52a7
Removing dup let
kylesoskin 039d1ff
fixing tests
kylesoskin 3933f1b
Adding ZSF increments
kylesoskin a664636
rubocop
kylesoskin 035b497
rubocop
kylesoskin 21575f9
Adding email job statsD
kylesoskin 742c734
Adding service constant
kylesoskin 64630b4
Fixing form num
kylesoskin 2418f16
Rubocop
kylesoskin 64509c0
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 6fabd4f
Removing lines to appease CI/CD
kylesoskin f15b918
Adding in ZeroSilentFailure Stuff
kylesoskin 9b84326
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin a40c3cd
Truing up with flippers removed upstream
kylesoskin c8ea3fe
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin e88bc15
Trying to cull lines to appease the line-counter
kylesoskin 404d886
Addressing PR comments
kylesoskin fee21cb
Correcting wrong variable
kylesoskin c81a860
Moving around logging var
kylesoskin 0d87bc5
Making a var a constant instead
kylesoskin 2378353
Making more readable
kylesoskin c5dd50a
Changing instance var to regular var
kylesoskin 07ff2d9
Fixing typo and extra db call
kylesoskin f9a77e9
Resolving failed test
kylesoskin 753affd
Fixing comment
kylesoskin 06819e2
Dont want to confuse these vars
kylesoskin 79f2f0e
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin d53e240
Fixing test
kylesoskin af755fb
Adding support for user account id in error message
kylesoskin 0414d9e
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 423def3
Fixing arg
kylesoskin 8bdd2ce
extracting out this code
kylesoskin 3461d4c
Refactoring to less vars
kylesoskin a1d470c
Fixing test cases
kylesoskin 90fddb0
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 643e726
Spelling mistake
kylesoskin 244f851
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin 6ffb51c
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin be2d183
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin a9dad1d
Merge branch 'master' into dbex/94144_trigger_email_on_polled_4142_fa…
kylesoskin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,15 @@ class FormSubmissionAttempt < ApplicationRecord | |
|
||
event :fail do | ||
after do | ||
form_type = form_submission.form_type | ||
log_info = { form_submission_id:, | ||
benefits_intake_uuid: form_submission&.benefits_intake_uuid, | ||
form_type:, | ||
user_account_uuid: form_submission.user_account_id } | ||
if should_send_simple_forms_email | ||
Rails.logger.info({ | ||
message: 'Preparing to send Form Submission Attempt error email', | ||
form_submission_id:, | ||
benefits_intake_uuid: form_submission.benefits_intake_uuid, | ||
form_type: form_submission.form_type | ||
}) | ||
simple_forms_enqueue_result_email(:error) | ||
simple_forms_api_email(log_info) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pulling this part out into a method! |
||
elsif form_type == CentralMail::SubmitForm4142Job::FORM4142_FORMSUBMISSION_TYPE | ||
form526_form4142_email(log_info) | ||
end | ||
end | ||
|
||
|
@@ -80,6 +81,41 @@ def log_status_change | |
|
||
private | ||
|
||
def simple_forms_api_email(log_info) | ||
Rails.logger.info('Preparing to send Form Submission Attempt error email', log_info) | ||
simple_forms_enqueue_result_email(:error) | ||
end | ||
|
||
def queue_form526_form4142_email(form526_submission_id, log_info) | ||
Rails.logger.info('Queuing Form526:Form4142 failure email to VaNotify', | ||
log_info.merge({ form526_submission_id: })) | ||
jid = EVSS::DisabilityCompensationForm::Form4142DocumentUploadFailureEmail.perform_async( | ||
form526_submission_id | ||
) | ||
Rails.logger.info('Queuing Form526:Form4142 failure email to VaNotify completed', | ||
log_info.merge({ jid:, form526_submission_id: })) | ||
end | ||
|
||
def form526_form4142_email(log_info) | ||
if Flipper.enabled?(CentralMail::SubmitForm4142Job::POLLED_FAILURE_EMAIL) | ||
queue_form526_form4142_email(Form526Submission.find_by(saved_claim_id:).id, log_info) | ||
else | ||
Rails.logger.info( | ||
'Would queue EVSS::DisabilityCompensationForm::Form4142DocumentUploadFailureEmail, but flipper is off.', | ||
log_info.merge({ form526_submission_id: }) | ||
) | ||
end | ||
rescue => e | ||
cl = caller_locations.first | ||
call_location = ZeroSilentFailures::Monitor::CallLocation.new( | ||
CentralMail::SubmitForm4142Job::FORM4142_DD_ZSF_FUNCTION, cl.path, cl.lineno | ||
) | ||
ZeroSilentFailures::Monitor.new(Form526Submission::ZSF_DD_TAG_SERVICE).log_silent_failure( | ||
log_info.merge({ error_class: e.class, error_message: e.message }), | ||
log_info[:user_account_uuid], call_location: | ||
) | ||
end | ||
|
||
def should_send_simple_forms_email | ||
simple_forms_form_number && Flipper.enabled?(:simple_forms_email_notifications) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,12 @@ | |
# TODO: Update Namespace once we are 100% done with CentralMail here | ||
module CentralMail | ||
class SubmitForm4142Job < EVSS::DisabilityCompensationForm::Job | ||
INITIAL_FAILURE_EMAIL = :form526_send_4142_failure_notification | ||
POLLING_FLIPPER_KEY = :disability_526_form4142_polling_records | ||
POLLED_FAILURE_EMAIL = :disability_526_form4142_polling_record_failure_email | ||
|
||
FORM4142_FORMSUBMISSION_TYPE = "#{Form526Submission::FORM_526}_#{Form526Submission::FORM_4142}".freeze | ||
FORM4142_DD_ZSF_FUNCTION = 'Form 526 Flow - Form 4142 failure email queuing' | ||
extend Logging::ThirdPartyTransaction::MethodWrapper | ||
|
||
# this is required to make instance variables available to logs via | ||
|
@@ -131,20 +137,39 @@ def lighthouse_service | |
@lighthouse_service ||= BenefitsIntakeService::Service.new(with_upload_location: true) | ||
end | ||
|
||
def upload_to_lighthouse | ||
Rails.logger.info( | ||
'Successful Form4142 Submission to Lighthouse', | ||
{ benefits_intake_uuid: lighthouse_service.uuid, submission_id: @submission_id } | ||
) | ||
|
||
payload = { | ||
upload_url: lighthouse_service.location, | ||
def payload_hash(lighthouse_service_location) | ||
{ | ||
upload_url: lighthouse_service_location, | ||
file: { file: @pdf_path, file_name: @pdf_path.split('/').last }, | ||
metadata: generate_metadata.to_json, | ||
attachments: [] | ||
} | ||
end | ||
|
||
def upload_to_lighthouse | ||
log_info = { benefits_intake_uuid: lighthouse_service.uuid, submission_id: @submission_id } | ||
|
||
Rails.logger.info( | ||
'Successful Form4142 Upload Intake UUID acquired from Lighthouse', | ||
log_info | ||
) | ||
|
||
payload = payload_hash(lighthouse_service.location) | ||
lighthouse_service.upload_doc(**payload) | ||
|
||
if Flipper.enabled?(POLLING_FLIPPER_KEY) | ||
form526_submission = Form526Submission.find(@submission_id) | ||
form_submission = FormSubmission.create( | ||
form_type: FORM4142_FORMSUBMISSION_TYPE, # form526_form4142 | ||
benefits_intake_uuid: lighthouse_service.uuid, | ||
form_data: '{}', # we have this already in the Form526Submission.form['form4142'] | ||
user_account: form526_submission.user_account, | ||
saved_claim: form526_submission.saved_claim | ||
kylesoskin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
FormSubmissionAttempt.create(form_submission:) | ||
log_info[:form_submission_id] = form_submission.id | ||
end | ||
Rails.logger.info('Successful Form4142 Submission to Lighthouse', log_info) | ||
kylesoskin marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always thought it was presumptive to have this log statement positioned before the |
||
end | ||
|
||
def generate_metadata | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe use docstrings or spell out
ZERO_SILENT_FAILUIRES
to make sure ZSF is clear to future generations? It's probably already a precedent in the codebase though so maybe too late? 🤷