-
Notifications
You must be signed in to change notification settings - Fork 166
Fixes a bug in the Verify By Mail reminder logic. #9916
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,12 @@ class GpoReminderSender | |
| LOCAL_DATABASE_TIMEOUT = 60_000 | ||
|
|
||
| def send_emails(for_letters_sent_before) | ||
| letter_eligible_range = | ||
| reminder_eligible_range = | ||
| IdentityConfig.store.usps_confirmation_max_days.days.ago..for_letters_sent_before | ||
|
|
||
| profiles_due_for_reminder(letter_eligible_range).each do |profile| | ||
| profiles_due_for_reminder(for_letters_sent_before).each do |profile| | ||
| profile.gpo_confirmation_codes.all.each do |gpo_code| | ||
| next if gpo_code.reminder_sent_at | ||
| next unless letter_eligible_range.cover?(gpo_code.created_at) | ||
| next unless reminder_eligible_range.cover?(gpo_code.created_at) | ||
|
|
||
| # Only email the user if we have an eligible code. | ||
| # Unlikely to have multiple codes since we only allow one letter/day | ||
|
|
@@ -22,17 +21,21 @@ def send_emails(for_letters_sent_before) | |
|
|
||
| private | ||
|
|
||
| def profiles_due_for_reminder(letter_eligible_range) | ||
| def profiles_due_for_reminder(for_letters_sent_before) | ||
| ActiveRecord::Base.transaction do | ||
| ActiveRecord::Base.connection.execute( | ||
| "SET LOCAL statement_timeout = #{LOCAL_DATABASE_TIMEOUT}", | ||
| ) | ||
|
|
||
| profile_eligible_range = | ||
| (IdentityConfig.store.usps_confirmation_max_days + | ||
| IdentityConfig.store.gpo_max_profile_age_to_send_letter_in_days). | ||
| days.ago..for_letters_sent_before | ||
| Profile.joins(:gpo_confirmation_codes). | ||
| where( | ||
| gpo_verification_pending_at: letter_eligible_range, | ||
| gpo_verification_pending_at: profile_eligible_range, | ||
| gpo_confirmation_codes: { reminder_sent_at: nil }, | ||
| deactivation_reason: [nil, :in_person_verification_pending], | ||
|
Contributor
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 thought this was here because a user might have a GPO letter for in-person proofing; is this not possible?
Contributor
Author
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. Sonia confirmed that that flag is deprecated and no longer used. |
||
| deactivation_reason: nil, | ||
| ) | ||
| end | ||
| end | ||
|
|
||
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.
That's a better name.