From 19aa7be182713fba7e7dd1b631f08ce346df78e8 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Tue, 8 Oct 2024 15:19:51 +0100 Subject: [PATCH] CLDC-3662: Recalculate status for 2024 logs missing la (#2681) --- .../recalculate_status_when_la_missing.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/tasks/recalculate_status_when_la_missing.rake b/lib/tasks/recalculate_status_when_la_missing.rake index 16af29cc7..1e304c6fa 100644 --- a/lib/tasks/recalculate_status_when_la_missing.rake +++ b/lib/tasks/recalculate_status_when_la_missing.rake @@ -17,3 +17,22 @@ task recalculate_status_missing_la: :environment do end end end + +desc "Recalculates status for 2024 completed logs with missing LA" +task recalculate_status_missing_la_2024: :environment do + LettingsLog.filter_by_year(2024).where(needstype: 1, la: nil, status: "completed").find_each do |log| + log.status = log.calculate_status + + unless log.save + Rails.logger.info "Could not save changes to lettings log #{log.id}" + end + end + + SalesLog.filter_by_year(2024).where(la: nil, status: "completed").find_each do |log| + log.status = log.calculate_status + + unless log.save + Rails.logger.info "Could not save changes to sales log #{log.id}" + end + end +end