Backfill reset pending timestamp on profiles with expired IPP enrollment#11130
Closed
Backfill reset pending timestamp on profiles with expired IPP enrollment#11130
Conversation
changelog: Internal, Data Normalization, Backfill reset pending timestamp on profiles with expired in-person enrollment
aduth
commented
Aug 22, 2024
Comment on lines
+93
to
+96
| profiles = InPersonEnrollment.where(status: :expired). | ||
| includes(:profile). | ||
| where.not(profile: { in_person_verification_pending_at: nil }). | ||
| map { |enrollment| enrollment.profile } |
Contributor
Author
There was a problem hiding this comment.
The idea with doing it inverted like this is that I'd assume there's much fewer records in the in-person enrollment table than in the profile table, and since we don't have any indices to leverage to optimize the query, this should hopefully be more efficient.
Contributor
There was a problem hiding this comment.
if we're worried about query time and table size, we could also try in_batches which breaks down the query into batches by ID (docs link)
Suggested change
| profiles = InPersonEnrollment.where(status: :expired). | |
| includes(:profile). | |
| where.not(profile: { in_person_verification_pending_at: nil }). | |
| map { |enrollment| enrollment.profile } | |
| profiles = InPersonEnrollment.where(status: :expired). | |
| includes(:profile). | |
| where.not(profile: { in_person_verification_pending_at: nil }). | |
| in_batches.flat_map do |batch| | |
| batch.map { |enrollment| enrollment.profile } | |
| end |
Contributor
Author
There was a problem hiding this comment.
Checking this with production data, I think it should probably be fine enough. I didn't even need to adjust the default timeout when running test queries.
Contributor
Author
|
Going to close this to be handled in LG-14320 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🛠 Summary of changes
Creates a Rake task to update profiles associated with expired in-person proofing enrollments, to reset the value of the profile's pending status and timestamp.
This is an alternative to a solution which involves updating queries to accommodate this mixed state: #11129
📜 Testing Plan
Override
config/application.ymlto prevent results job from automatically marking pending profiles as successful in local development:rails consoleInPersonEnrollment.last.update(status: :expired)rake profiles:backfill_expired_pending_in_person_verification UPDATE_PROFILES=trueBefore: You'd be redirected to the account page (wrong), and the account page would raise an exception when trying to access
due_dateproperty on the pending enrollmentAfter: You're redirected into the identity verification flow