-
Notifications
You must be signed in to change notification settings - Fork 66
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
#90355 [10-10 Health Apps] Improve code quality for shared code #20022
Open
JoshingYou1
wants to merge
32
commits into
master
Choose a base branch
from
90355_1010_apps_improve_code_quality
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.
+901
−518
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
eceeff9
Created a new enrollment system service to help with code readability
JoshingYou1 7fe7ebf
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 1c48fca
Fixed linting issues
JoshingYou1 fd68cdd
Fixed linting issues
JoshingYou1 92a5f1f
Removed some unused test code and updated the swagger specs for HCA
JoshingYou1 993d293
Fixed some failing tests
JoshingYou1 874539a
Fixed a couple more failing tests
JoshingYou1 03066c6
Separated tests with flipper enabled and disabled
JoshingYou1 6f18f95
Fixed linting issue
JoshingYou1 efb5141
Fixed linting issue
JoshingYou1 f2a6d59
Fixed linting issues
JoshingYou1 49c107b
Fixed linting issues
JoshingYou1 ae3a419
Fixed linting issue
JoshingYou1 9347b9b
Removed some code changes that were made in a different branch
JoshingYou1 35b9cfb
Merged from master
JoshingYou1 7d05fde
Cleaned up some test code
JoshingYou1 afe1337
Fixed some linting errors
JoshingYou1 35a5789
Fixed some more linting errors
JoshingYou1 8fff4f5
Fixed another linting issue
JoshingYou1 4683176
Fixed another linting issue
JoshingYou1 827217d
Fixed some failing tests
JoshingYou1 19b426f
Tried to fix a linting issue
JoshingYou1 9efcd0a
Tried to fix a linting issue
JoshingYou1 761d5f2
test: trigger preview environment
JoshingYou1 d1599d5
test: trigger preview environment
JoshingYou1 ec715c9
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 c891ec6
Merged from master
JoshingYou1 daf3fe7
Fixed linting issues
JoshingYou1 fa9eb40
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 37e125d
Fixed linting issues
JoshingYou1 154ded0
test: trigger preview environment
JoshingYou1 88da1e2
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
require 'hca/ezr_postfill' | ||
require 'va1010_forms/utils' | ||
require 'hca/overrides_parser' | ||
require 'va1010_forms/enrollment_system/service' | ||
|
||
module Form1010Ezr | ||
class Service < Common::Client::Base | ||
|
@@ -38,23 +39,25 @@ def submit_async(parsed_form) | |
|
||
def submit_sync(parsed_form) | ||
res = with_monitoring do | ||
es_submit(parsed_form, HealthCareApplication.get_user_identifier(@user), FORM_ID) | ||
if Flipper.enabled?(:va1010_forms_enrollment_system_service_enabled) | ||
VA1010Forms::EnrollmentSystem::Service.new( | ||
HealthCareApplication.get_user_identifier(@user) | ||
).submit(parsed_form, FORM_ID) | ||
else | ||
es_submit(parsed_form, HealthCareApplication.get_user_identifier(@user), FORM_ID) | ||
end | ||
end | ||
|
||
# Log the 'formSubmissionId' for successful submissions | ||
Rails.logger.info( | ||
'1010EZR successfully submitted', | ||
submission_id: res[:formSubmissionId], | ||
veteran_initials: veteran_initials(parsed_form) | ||
) | ||
log_successful_submission(res[:formSubmissionId], veteran_initials(parsed_form)) | ||
|
||
if parsed_form['attachments'].present? | ||
StatsD.increment("#{Form1010Ezr::Service::STATSD_KEY_PREFIX}.submission_with_attachment") | ||
end | ||
|
||
res | ||
rescue => e | ||
log_and_raise_error(e, parsed_form) | ||
log_submission_failure(parsed_form) | ||
raise e | ||
end | ||
|
||
# @param [HashWithIndifferentAccess] parsed_form JSON form data | ||
|
@@ -66,7 +69,8 @@ def submit_form(parsed_form) | |
|
||
submit_async(parsed_form) | ||
rescue => e | ||
log_and_raise_error(e, parsed_form) | ||
log_submission_failure(parsed_form) | ||
raise e | ||
end | ||
|
||
def log_submission_failure(parsed_form) | ||
|
@@ -107,11 +111,8 @@ def validate_form(parsed_form) | |
) | ||
end | ||
|
||
log_validation_errors(parsed_form) | ||
log_validation_errors(validation_errors, parsed_form) | ||
|
||
Rails.logger.error( | ||
"10-10EZR form validation failed. Form does not match schema. Error list: #{validation_errors}" | ||
) | ||
raise Common::Exceptions::SchemaValidationErrors, validation_errors | ||
end | ||
end | ||
|
@@ -168,19 +169,26 @@ def add_financial_flag(parsed_form) | |
end | ||
end | ||
|
||
def log_validation_errors(parsed_form) | ||
# @param [Hash] errors | ||
def log_validation_errors(errors, parsed_form) | ||
StatsD.increment("#{Form1010Ezr::Service::STATSD_KEY_PREFIX}.validation_error") | ||
|
||
Rails.logger.error( | ||
"10-10EZR form validation failed. Form does not match schema. Error list: #{errors}" | ||
) | ||
|
||
PersonalInformationLog.create( | ||
data: parsed_form, | ||
error_class: 'Form1010Ezr ValidationError' | ||
) | ||
end | ||
|
||
def log_and_raise_error(error, form) | ||
log_submission_failure(form) | ||
Rails.logger.error "10-10EZR form submission failed: #{error.message}" | ||
raise error | ||
def log_successful_submission(submission_id, veteran_initials) | ||
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 had to create this method because the |
||
Rails.logger.info( | ||
'1010EZR successfully submitted', | ||
submission_id:, | ||
veteran_initials: | ||
) | ||
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
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.
This logger was moved into the
log_validation_errors
method.