Skip to content
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

Use New Status Field to Maintain InProgressForm Data for Dependents Application #16097

Merged
merged 9 commits into from
May 9, 2024

Conversation

tfink419
Copy link
Contributor

@tfink419 tfink419 commented Mar 26, 2024

Summary

Related issue(s)

department-of-veterans-affairs/va.gov-team/issues/77171

Testing done

  • New code is covered by unit tests
  • In progress form would be deleted immediately, now it is saved until submission succeeds or fails the final time
  • Submit a dependents change application and check if the form still appears immediately after submission, and that it will reappear after the status is changed back (normally after failures)

Screenshots

Pending Submission:
Screenshot 2024-03-15 at 15 38 16

Processing Submission:
Screenshot 2024-03-15 at 15 38 35

What areas of the site does it impact?

Dependents application submission

Acceptance criteria

  • ~ I fixed|updated|added unit tests and integration tests for each feature (if applicable). ~
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog or Grafana (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

@va-vsp-bot
Copy link
Collaborator

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:

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) was deleted but its reference still exists in CODEOWNERS. Please update the .github/CODEOWNERS file and delete the entry for the Offending file:

@tfink419 tfink419 added the dependents-benefits Label used for Pull Requests that impact Add/Remove Dependents claims (686c/674) label Mar 26, 2024
Base automatically changed from dbex-inprogress-form-state-migration-77171 to master April 10, 2024 20:02
@va-vfs-bot va-vfs-bot temporarily deployed to dbex-fix-inprogress-form-state-77171/main/main April 10, 2024 20:14 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to dbex-fix-inprogress-form-state-77171/main/main April 24, 2024 17:31 Inactive
tblackwe
tblackwe previously approved these changes Apr 24, 2024
@tfink419 tfink419 marked this pull request as ready for review April 24, 2024 22:13
@tfink419 tfink419 requested review from a team as code owners April 24, 2024 22:13
micahaspyr
micahaspyr previously approved these changes Apr 24, 2024
Copy link
Contributor

@micahaspyr micahaspyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bramleyjl
bramleyjl previously approved these changes Apr 25, 2024
@RachalCassity
Copy link
Member

@tfink419 Can you confirm the CODEOWNERS file is correct for all of these files? Should the @department-of-veterans-affairs/benefits-dependents-management be added to these other files in CODEOWNERS?

@tfink419 tfink419 dismissed stale reviews from bramleyjl and micahaspyr via 9b219d6 April 25, 2024 17:48
tblackwe
tblackwe previously approved these changes Apr 25, 2024
@va-vfs-bot va-vfs-bot temporarily deployed to dbex-fix-inprogress-form-state-77171/main/main April 25, 2024 17:52 Inactive
@RachalCassity
Copy link
Member

@tfink419 Is this PR still relevant?

@tfink419
Copy link
Contributor Author

tfink419 commented May 1, 2024

@tfink419 Is this PR still relevant?

@RachalCassity
Yes this PR needs to be approved and merged

@va-vfs-bot va-vfs-bot temporarily deployed to dbex-fix-inprogress-form-state-77171/main/main May 1, 2024 19:39 Inactive
@RachalCassity
Copy link
Member

I noticed that the in_progress_form shows has_many :form_submissions, dependent: :nullify. Would it be appropriate to add add_foreign_key :form_submissions, :in_progress_forms, column: :in_progress_form_id, on_delete: :nullify.

I also noticed this in SavedClaim and UserAccount. These should be in the schema as well.

@tfink419
Copy link
Contributor Author

tfink419 commented May 2, 2024

I noticed that the in_progress_form shows has_many :form_submissions, dependent: :nullify. Would it be appropriate to add add_foreign_key :form_submissions, :in_progress_forms, column: :in_progress_form_id, on_delete: :nullify.

I also noticed this in SavedClaim and UserAccount. These should be in the schema as well.

@RachalCassity I do see the foreign key constraints in the schema already. I can add them to the model files

@tfink419
Copy link
Contributor Author

tfink419 commented May 2, 2024

I noticed that the in_progress_form shows has_many :form_submissions, dependent: :nullify. Would it be appropriate to add add_foreign_key :form_submissions, :in_progress_forms, column: :in_progress_form_id, on_delete: :nullify.
I also noticed this in SavedClaim and UserAccount. These should be in the schema as well.

@RachalCassity I do see the foreign key constraints in the schema already. I can add them to the model files

@RachalCassity I'm not sure anything should be done, form submission has those 3 other models as optional which aligns with nullifying the id.

@RachalCassity
Copy link
Member

RachalCassity commented May 3, 2024

@tfink419 Thank you for your patience. In the past, I have seen errors with InProgressForms which is why I'm digging through the models and controllers. Here's one sentry issue, here. I noticed during the update, a InProgressForm is initialized here:

    def update
      form = InProgressForm.form_for_user(form_id, @current_user) ||
             InProgressForm.new(form_id:, user_uuid: @current_user.uuid)

Would it make sense to use find_or_initialize_by?

    def update
      form = InProgressForm.form_for_user(form_id, @current_user) ||
             InProgressForm.find_or_intialize_by(form_id:, user_uuid: @current_user.uuid)

I also noticed in the model, the user.account is being used.

  def self.form_for_user(form_id, user)
    user_uuid_form = InProgressForm.find_by(form_id:, user_uuid: user.uuid)
    user_account_form = InProgressForm.find_by(form_id:, user_account: user.user_account) if user.user_account
    user_uuid_form || user_account_form
  end

I'm wondering if this is the issue:
InProgressForm being updated contains the user.uuid but in the form_for_user method, the user_account is taking precedence. Since the InProgressForm does not contain the account info, a new form is initialized in the controller.

@RachalCassity RachalCassity self-assigned this May 6, 2024
@tfink419
Copy link
Contributor Author

tfink419 commented May 8, 2024

@RachalCassity I'll look into it for a new ticket but for now this PR is overdue to be merged so I will proceed with that

Copy link
Contributor

@rileyanderson rileyanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from an identity perspective. One small unrelated suggestion

@@ -17,7 +17,7 @@ def create
dependent_service.submit_686c_form(claim)

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
clear_saved_form(claim.form_id)
# clear_saved_form(claim.form_id) # We do not want to destroy the InProgressForm for this submission
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this in a new ticket along with the suggestions from Rachal. I wanted to leave that comment in initially to point out the change in the logic

@tfink419 tfink419 merged commit 8e6112a into master May 9, 2024
19 checks passed
@tfink419 tfink419 deleted the dbex-fix-inprogress-form-state-77171 branch May 9, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependents-benefits Label used for Pull Requests that impact Add/Remove Dependents claims (686c/674) waiting-for-info
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants