-
Notifications
You must be signed in to change notification settings - Fork 166
Jmax/lg 9565 two week gpo letter reminder email #9001
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
Merged
jmax-gsa
merged 36 commits into
main
from
jmax/LG-9565-two-week-gpo-letter-reminder-email
Aug 21, 2023
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
f116816
Created mailer method, preview, and placeholder for content.
jmax-gsa 615abf4
Email formatting
jmax-gsa 7784bf7
Moved strings out to i18m Yaml
jmax-gsa 1f86b76
Lint nits
jmax-gsa 0dc14bc
French and Spanish strings
jmax-gsa 72caa22
Lint and i18n nits
jmax-gsa ab2a75a
Point email links at correct targets
jmax-gsa 41c1f65
Added reminder_sent_at to usps_confirmations table
jmax-gsa 4736e90
Point links at correct targets, take 2.
jmax-gsa b72eada
Specs for basic cases.
jmax-gsa db0d993
Add time range to profile select.
jmax-gsa 6878977
Add checks for time and reminder already sent
jmax-gsa 5a52cce
Hande users with multiple emails
jmax-gsa b403690
Added mailer spec for gpo_reminder
jmax-gsa 922be1e
Actually set up the job.
jmax-gsa 3450849
Added analytics event for reminder email sent.
jmax-gsa ef01c75
Lint nit and changelog
jmax-gsa 44766b4
Added spec for user canceling GPO verification
jmax-gsa 0de4ca5
Pointed at new 'request another letter' page.
jmax-gsa 7fbdb71
Review comments
jmax-gsa 13341b9
Review comment
jmax-gsa eb3f24d
Normalize YAML
jmax-gsa 0a0a36d
Review comment
jmax-gsa d64357a
Review comment
jmax-gsa affdbf7
Lint
jmax-gsa f3489a0
Update spec/jobs/gpo_reminder_job_spec.rb
jmax-gsa 74b9dd6
Update spec/jobs/gpo_reminder_job_spec.rb
jmax-gsa b719f1c
Fixed preview
jmax-gsa d5a5304
Review comments
jmax-gsa e36a6ee
Review comments.
jmax-gsa 7dbf07a
Added spec for user who completes GPO proofing before their reminder
jmax-gsa f6edd1c
Fixed spec.
jmax-gsa 0227318
Spec for updating sent_at time
jmax-gsa 54f160f
Review comments.
jmax-gsa e563453
Review comment
jmax-gsa b49d2d6
Lint nits
jmax-gsa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class GpoReminderJob < ApplicationJob | ||
| queue_as :low | ||
|
|
||
| # Send email reminders to people with USPS proofing letters whose | ||
| # letters were sent a while ago, and haven't yet entered their code | ||
| def perform(cutoff_time_for_sending_reminders) | ||
| GpoReminderSender.new. | ||
| send_emails(cutoff_time_for_sending_reminders) | ||
| end | ||
| end |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| class GpoReminderSender | ||
| def send_emails(for_letters_sent_before) | ||
| profiles_due_for_reminder = Profile.joins(:gpo_confirmation_codes). | ||
| where( | ||
| gpo_verification_pending_at: ..for_letters_sent_before, | ||
| gpo_confirmation_codes: { reminder_sent_at: nil }, | ||
| ) | ||
|
|
||
| profiles_due_for_reminder.each do |profile| | ||
| profile.user.send_email_to_all_addresses(:gpo_reminder) | ||
| profile.gpo_confirmation_codes.first.update(reminder_sent_at: Time.zone.now) | ||
| analytics.idv_gpo_reminder_email_sent(user_id: profile.user.uuid) | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def analytics | ||
| Analytics.new(user: AnonymousUser.new, request: nil, session: {}, sp: nil) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <p> | ||
| <%= help_link = link_to( | ||
| t('idv.troubleshooting.options.learn_more_verify_by_mail'), | ||
| help_center_redirect_url( | ||
| category: 'verify-your-identity', | ||
| article: 'verify-your-address-by-mail', | ||
| flow: :idv, | ||
| step: :gpo_send_letter, | ||
| ), | ||
| { style: "text-decoration: 'underline'" }, | ||
| ) | ||
|
|
||
| t( | ||
| 'idv.messages.gpo_reminder.body_html', | ||
| date_letter_was_sent: @gpo_verification_pending_at, | ||
| app_name: APP_NAME, | ||
| help_link: help_link, | ||
| ) %> | ||
| </p> | ||
|
|
||
| <table class="button expanded large radius"> | ||
| <tbody> | ||
| <tr> | ||
| <td> | ||
| <table style="margin-bottom: 1em; margin-top: 1em"> | ||
| <tbody> | ||
| <tr> | ||
| <td style="text-align: center"> | ||
| <%= link_to t('idv.messages.gpo_reminder.finish'), | ||
| idv_gpo_verify_url, | ||
| target: '_blank', | ||
| class: 'float-center', | ||
| align: 'center', | ||
| rel: 'noopener' %> | ||
| </td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| </td> | ||
| <td class="expander"></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| <p> | ||
| <%= t( | ||
| 'idv.messages.gpo_reminder.did_not_get_a_letter_html', | ||
| another_letter_link_html: link_to( | ||
| t('idv.messages.gpo_reminder.sign_in_and_request_another_letter'), | ||
| idv_gpo_verify_url(did_not_receive_letter: 1), | ||
| { style: "text-decoration: 'underline'" }, | ||
| ), | ||
| ) %> | ||
| </p> |
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
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
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
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
8 changes: 8 additions & 0 deletions
8
db/primary_migrate/20230809194211_add_reminder_sent_at_to_usps_confirmation_codes.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| class AddReminderSentAtToUspsConfirmationCodes < ActiveRecord::Migration[7.0] | ||
| disable_ddl_transaction! | ||
|
|
||
| def change | ||
| add_column :usps_confirmation_codes, :reminder_sent_at, :datetime, precision: nil | ||
| add_index :usps_confirmation_codes, :reminder_sent_at, algorithm: :concurrently | ||
| end | ||
| end | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe GpoReminderJob do | ||
| let(:wait_before_sending_reminder) { 14.days } | ||
|
|
||
| describe '#perform' do | ||
| subject(:perform) { job.perform(wait_before_sending_reminder.ago) } | ||
|
|
||
| let(:job) { GpoReminderJob.new } | ||
| let(:user) { create(:user, :with_pending_gpo_profile) } | ||
| let(:pending_profile) { user.pending_profile } | ||
| let(:job_analytics) { FakeAnalytics.new } | ||
|
|
||
| before do | ||
| pending_profile.update( | ||
| gpo_verification_pending_at: wait_before_sending_reminder.ago, | ||
| ) | ||
| allow(Analytics).to receive(:new).and_return(job_analytics) | ||
| end | ||
|
|
||
| it 'sends reminder emails' do | ||
| expect { perform }.to change { ActionMailer::Base.deliveries.count }.by(1) | ||
| expect(job_analytics).to have_logged_event( | ||
| 'IdV: gpo reminder email sent', | ||
| ) | ||
| end | ||
| end | ||
| end |
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
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
Oops, something went wrong.
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.
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.
Wondering if we need an index here. Are we querying the usps_confirmation_codes table by when reminders were sent?
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, we are querying that, although it's not immediately obvious. The index is for the benefit of the code in
GpoReminderSender, where we do a join that this index helps.