From 6c2488083fdcfa07cbcd64249ab75329c91366c9 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 16 Nov 2023 12:48:39 +0000 Subject: [PATCH] Don't send reminders for reviewed reference requests 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). --- app/models/application_form.rb | 9 +++++---- .../assessor_interface/application_forms/status.html.erb | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/application_form.rb b/app/models/application_form.rb index 1f52837f1b..f1de783c2a 100644 --- a/app/models/application_form.rb +++ b/app/models/application_form.rb @@ -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, @@ -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 @@ -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 diff --git a/app/views/assessor_interface/application_forms/status.html.erb b/app/views/assessor_interface/application_forms/status.html.erb index 9bafc26a6f..a660ad5cfa 100644 --- a/app/views/assessor_interface/application_forms/status.html.erb +++ b/app/views/assessor_interface/application_forms/status.html.erb @@ -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?