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
Add job to send virtual hearing reminder emails #15581
Conversation
…pellant/representative
…_emails_sent? check
Generated by 🚫 Danger |
Code Climate has analyzed commit 31ffa4c and detected 0 issues on this pull request. View more on Code Climate. |
@@ -7,10 +7,16 @@ class RecipientIsDeceasedVeteran < StandardError; end | |||
|
|||
def initialize(virtual_hearing:, type:) | |||
@virtual_hearing = virtual_hearing | |||
@type = type | |||
@type = type.to_s |
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.
Small refactor here so we don't have to call to_s
when we're using type
email_address: recipient.email, | ||
external_message_id: external_id, | ||
recipient_role: recipient_is_veteran ? "veteran" : recipient.title.downcase, | ||
sent_by: virtual_hearing.updated_by | ||
sent_by: type.ends_with?("reminder") ? User.system_user : virtual_hearing.updated_by |
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.
Tagging the system user as the person who sent the email, since technically no one is triggering the email to be 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.
That makes sense
class VirtualHearings::SendReminderEmailsJob < ApplicationJob | ||
def perform | ||
VirtualHearingRepository.maybe_ready_for_reminder_email.each do |virtual_hearing| | ||
send_reminder_emails(virtual_hearing) |
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.
VirtualHearing::SendEmail
seems pretty good at handling errors, so I don't know if we need to handle errors here? I could add a very broad begin/rescue
db/migrate/20201104175215_add_reminder_email_flags_to_virtual_hearings.rb
Outdated
Show resolved
Hide resolved
db/migrate/20201104175215_add_reminder_email_flags_to_virtual_hearings.rb
Outdated
Show resolved
Hide resolved
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.
approved with some comments and suggestions!
email_address: recipient.email, | ||
external_message_id: external_id, | ||
recipient_role: recipient_is_veteran ? "veteran" : recipient.title.downcase, | ||
sent_by: virtual_hearing.updated_by | ||
sent_by: type.ends_with?("reminder") ? User.system_user : virtual_hearing.updated_by |
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 makes sense
|
||
def days_from_hearing_day_to_last_sent_reminder | ||
# Pick arbitrarily big value if the reminder has never been sent. | ||
return 9999 if last_sent_reminder.nil? |
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.
what do you think about using Float::INFINITY
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.
I think that would work! Let me try that and see if the tests still pass
…nfirmed within the reminder period
Resolves #15400
Resolves https://vajira.max.gov/browse/CASEFLOW-194
Description
VirtualHearings::SendReminderEmailsJob
to send reminder emails on a schedule (TBD)VirtualHearingRepository
with new method to find virtual hearings that might need reminder emailsVirtualHearings::ReminderService
to determine when reminder emails need to be sentVirtualHearings::SendEmail
to send reminder emailsappellant_reminder_sent
andrepresentative_reminder_sent
Acceptance Criteria
New templateCompleted in Create templates for virtual hearing reminder emails #15557Recording metrics on sends in Datadog, also alerting with failed sends as we do now for confirmationShould be handled already by logic inVirtualHearings::SendEmail
Database Changes
Only for Schema Changes
Timestamps (created_at, updated_at) for new tablesCaseflow::Migration
, especially when adding indexes (useadd_safe_index
)migrate:rollback
works as desired (change
supported functions)Query profiling performed (eyeball Rails log, check bullet and fasterer output)Appropriate indexes added (especially for foreign keys, polymorphic columns, unique constraints, and Rails scopes)make docs
(after runningmake migrate
)Any non-obvious semantics or logic useful for interpreting database data is documented at Caseflow Data Model and Dictionary