-
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
[10-10EZ] Update LogEmailDiffJob to not use redis key #19398
Conversation
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: |
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: |
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: |
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: |
@@ -28,5 +36,29 @@ def perform(in_progress_form_id, user_uuid) | |||
) | |||
$redis.set(redis_key, 't') | |||
end | |||
|
|||
def log_different_email(in_progress_form_id, user_uuid) | |||
return if InProgressEmailMatchLog.exists?(user_uuid:, in_progress_form_id:) |
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.
would race conditions be a concern in this method?
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 don't think so, because of the unique constraint in this PR. If two concurrent jobs both returned true for exists?
, one would fail when trying the create since one of them would successfully create the record and the index would throw the exception (which would just kill the job). I think that should handle it?
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'm not totally sure the job would be killed since you're using create
and not create!
but yes, the unique constraint should prevent dupes.
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, you're right. Poor wording on my part. The create will fail, and since it's at the end of the job and there are no retries for this job, it wouldn't cause any other issues. But I think we should be okay as far as race conditions, though. I appreciate the call out on it! 👍
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 don't know that we gain anything by the create!
? Although I guess if it throws an exception I think we'd have some automatic logging that would catch it, so if we did find we were running into issues with this that could be a way to identify it 🤔
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 no biggie, it was good exercise to think through these things though
"api.1010ez.in_progress_form_email.#{tag_text}" | ||
) | ||
|
||
InProgressEmailMatchLog.create(user_uuid:, in_progress_form_id:) |
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.
So this would create a record if the emails are the same and if they are different. The method is called log_different_email
but it looks like it creates a record even if it's the same?
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 could probably be clearer. The names for this one are tricky to me. Would log_email_difference
make more sense? Open to suggestions on the name 🙂
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.
Yes, I don't like to knock names if I don't have a better suggestion but log_email_difference
does seem closer to what's happening 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.
lgtm , just confirm if you want to use InProgressEmailMatchLog.create!
over InProgressEmailMatchLog.create
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: |
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: |
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: |
def log_email_difference(in_progress_form_id, user_uuid) | ||
return if FormEmailMatchesProfileLog.exists?(user_uuid:, in_progress_form_id:) | ||
|
||
in_progress_form = InProgressForm.find_by(id: in_progress_form_id) |
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 kept the same logic as the redis version here. If we do any refactors I plan to do those later just to keep the changes here scope to the database vs redis usage and not the logic in this method.
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.
LGTM. Interesting pattern with the specs - makes it nicely readable!
Backend-review-group approval confirmed. |
Summary
HCA::LogEmailDiffJob
to not use a redis key that is never deleted to log if an email address is different between the VA Profile email and the 10-10EZ submission email address. Using a new table to store the user uuid and the in progress form id instead of expecting a redis key to always exist.hca_log_email_diff_in_progress_form
.Related issue(s)
Testing done
What areas of the site does it impact?
(Describe what parts of the site are impacted andifcode touched other areas)
Acceptance criteria
Requested Feedback
(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?