-
Notifications
You must be signed in to change notification settings - Fork 56
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
DBEX: Form526Submission submit_endpoint data migration #16693
DBEX: Form526Submission submit_endpoint data migration #16693
Conversation
Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: lib/data_migrations/form526_submission_submit_endpoint_update.rb |
Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: lib/data_migrations/form526_submission_submit_endpoint_update.rb |
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.
Main blocker is the question about setting variables in the tests and skipping model validations in the backfill script kickoff, and some style nits.
@@ -118,7 +118,8 @@ def create_submission(saved_claim) | |||
user_account: @current_user.user_account, | |||
saved_claim_id: saved_claim.id, | |||
auth_headers_json: auth_headers.to_json, | |||
form_json: saved_claim.to_submission_data(@current_user) | |||
form_json: saved_claim.to_submission_data(@current_user), | |||
submit_endpoint: includes_toxic_exposure? ? :claims_api : :evss |
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: looks like the linter didn't mind but the ternary operator here is a little hard to read with the symbols, may be consider doing this in a method with if statements
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.
Utilized strings in place of symbols for improved readability. (see d2a1c09)
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.
Good call - one sanity check just confirming it doesn't matter downstream if you change the type of this value?
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.
I believe the most common method for setting the value of an enum attribute is by using the symbolic key, but using the string representation of the symbolic key is also valid.
Form526Submission.where(submit_endpoint: nil).in_batches do |batch| | ||
# rubocop:disable Rails/SkipsModelValidations | ||
batch.update_all(submit_endpoint: :evss) | ||
# rubocop:enable Rails/SkipsModelValidations |
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.
Hmm is this an existing precedent for data migrations? I feel like skipping validations is quite dangerous
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.
Following Platform's guidance here as well as optimizing performance when bulk updating.
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.
Hmm I didn't see anything in there about skipping validations am I missing something? Is there a reason why you needed to skip them? At the very least if there is a good reason it would be good to have it as a comment and in the git history even if the file gets removed
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.
what does the Validation look like if we added it? I can understand both points here.
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.
we know what we are doing. we created a new column, and are updating all the old claims with the correct value.
post("/v0/disability_compensation_form/submit_all_claim#{query_param}", params: all_claims_form, headers:) | ||
expect(response).to have_http_status(:ok) | ||
expect(response).to match_response_schema('submit_disability_form') | ||
submission = Form526Submission.last |
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.
Using first
and last
to test a side effect of an action always makes me nervous because it's not deterministic. Is there any way around this you can think of?
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.
If the /v0/disability_compensation_form/submit_all_claim
endpoint is designed to create a single Form526Submission
record, then using Form526Submission.last
to retrieve that record for testing should be reliable. But I did add to each test an expectation that there is only a single Form526Submission
record. (see d2a1c09)
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.
Yeah that's one way to get around it which is probably fine for now.
Outside of this example: my concern with using first and last in general is there could be side effects elsewhere in the code creating records you might not know about or other data created by a before block in the tests or anything like that. Or data that gets seeded for running every test. And then maybe the endpoint doesn't work as expected and because there is a record that already existed that would get returned from Form526Submission.last
instead. It's probably unlikely but something to consider when writing tests. What I'm basically saying is assuming the latest record in a table was one you created without any other identifier could lead to problems if that makes sense.
Form526Submission.where(submit_endpoint: nil).in_batches do |batch| | ||
# rubocop:disable Rails/SkipsModelValidations | ||
batch.update_all(submit_endpoint: :evss) | ||
# rubocop:enable Rails/SkipsModelValidations |
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.
what does the Validation look like if we added it? I can understand both points here.
Form526Submission.where(submit_endpoint: nil).in_batches do |batch| | ||
# rubocop:disable Rails/SkipsModelValidations | ||
batch.update_all(submit_endpoint: :evss) | ||
# rubocop:enable Rails/SkipsModelValidations |
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.
we know what we are doing. we created a new column, and are updating all the old claims with the correct value.
…int-data-migration
@NB28VT – regarding your change request:
All raised issues and suggestions have been addressed in d2a1c09. Comments corresponding to each correction have been updated to include a link to the commit. |
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.
Just one sanity check on the data type changing which I think is fine but worth a quick look, otherwise LGTM
Not sure where we landed re: skipping the validations, but if that's a no no I assume the platform will call it out in their review?
Rake task to migrate historic
Form526Submission
data, setting allsubmit_endpoint
values toevss
, signifying the service API used for past and current claim submissions.Also included in this PR:
submit_endpoint
will initially be set asclaims_api
.claims_api
endpoint.includes_toxic_exposure
query param.submit_endpoint
is updated tobenefits_intake_api
, which receives all backup submissions of form 526 that fail primary delivery to EVSS.Summary
YES/NOdisability_526_toxic_exposure
Flippersubmit_endpoint
attribute, and tests behaviorsubmit_endpoint
attribute for all pre-existingForm526Submission
records to have an enum value ofevss
submit_endpoint
, based on the inclusion/value of aincludes_toxic_exposure
query param, as well as updating the endpoint's value if submission is processed via a backup processRelated issue(s)
Testing done
Form526Submission
recordssubmit_endpoint
value of allForm526Submission
records has been updated toevss
after running the rake taskWhat areas of the site does it impact?
Acceptance criteria