diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-10-23 09:07:28 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-10-23 09:07:28 +0100 |
commit | 8d9e273deb8a1365ec40fc0a395a07f69745725a (patch) | |
tree | cf456e41765cd2817416174efea7349a85357501 | |
parent | f71e933e7a535d1734b2e62d5a034316bf17d408 (diff) |
Don't keep re-calling info_request.calculate_status
-rw-r--r-- | app/models/request_mailer.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index f4f69bbc6..ec45ac42a 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -265,10 +265,11 @@ class RequestMailer < ApplicationMailer for info_request in info_requests alert_event_id = info_request.last_event_forming_initial_request.id # Only overdue requests - if ['waiting_response_overdue', 'waiting_response_very_overdue'].include?(info_request.calculate_status) - if info_request.calculate_status == 'waiting_response_overdue' + calculated_status = info_request.calculate_status + if ['waiting_response_overdue', 'waiting_response_very_overdue'].include?(calculated_status) + if calculated_status == 'waiting_response_overdue' alert_type = 'overdue_1' - elsif info_request.calculate_status == 'waiting_response_very_overdue' + elsif calculated_status == 'waiting_response_very_overdue' alert_type = 'very_overdue_1' else raise "unknown request status" @@ -293,9 +294,9 @@ class RequestMailer < ApplicationMailer # Only send the alert if the user can act on it by making a followup # (otherwise they are banned, and there is no point sending it) if info_request.user.can_make_followup? - if info_request.calculate_status == 'waiting_response_overdue' + if calculated_status == 'waiting_response_overdue' RequestMailer.deliver_overdue_alert(info_request, info_request.user) - elsif info_request.calculate_status == 'waiting_response_very_overdue' + elsif calculated_status == 'waiting_response_very_overdue' RequestMailer.deliver_very_overdue_alert(info_request, info_request.user) else raise "unknown request status" |