Skip to content

Commit

Permalink
Don't send reminders for reviewed reference requests
Browse files Browse the repository at this point in the history
This changes the logic on when to send reminder emails to applicants to
avoid sending them if the reference request has been reviewed
(presumably rejected if it's not been received).
  • Loading branch information
thomasleese committed Nov 16, 2023
1 parent 3684ccd commit 6c24880
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/models/application_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def should_send_reminder_email?(name, number_of_reminders_sent)
(days_until_expired <= 14 && number_of_reminders_sent.zero?) ||
(days_until_expired <= 7 && number_of_reminders_sent == 1)
when "references"
unreviewed_reference_requests.any? do |reference_request|
reference_requests_not_yet_received_or_rejected.any? do |reference_request|
reference_request.should_send_reminder_email?(
"expiration",
number_of_reminders_sent,
Expand All @@ -302,7 +302,8 @@ def send_reminder_email(name, number_of_reminders_sent)
.with(
teacher:,
number_of_reminders_sent:,
reference_requests: unreviewed_reference_requests.to_a,
reference_requests:
reference_requests_not_yet_received_or_rejected.to_a,
)
.references_reminder
.deliver_later
Expand All @@ -327,10 +328,10 @@ def build_documents
documents.build(document_type: :written_statement)
end

def unreviewed_reference_requests
def reference_requests_not_yet_received_or_rejected
ReferenceRequest
.joins(:work_history)
.where(work_histories: { application_form_id: id })
.where(received_at: nil, expired_at: nil)
.where(received_at: nil, verify_passed: nil, review_passed: nil)
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% title = if @view_object.assessment.review?
"An assessor will now review the application and make a decision on awarding or declining QTS."
"Application sent for review"
elsif @view_object.application_form.waiting_on?
"Reference requests sent successfully"
elsif @view_object.application_form.awarded?
Expand Down

0 comments on commit 6c24880

Please sign in to comment.