Skip to content

Commit

Permalink
Merge pull request #1811 from DFE-Digital/limit-reminder-emails
Browse files Browse the repository at this point in the history
Don't send reminders for reviewed reference requests
  • Loading branch information
thomasleese authored Nov 16, 2023
2 parents 3684ccd + 6c24880 commit 7abf44e
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 7abf44e

Please sign in to comment.