From 032cecf3f830cc897e0923bee40c3de6156413fb Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Wed, 10 Jul 2024 16:26:55 +0100 Subject: [PATCH] CLDC-3482: Task to recalculate status for 2023 logs missing la (#2495) --- .../recalculate_status_when_la_missing.rake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tasks/recalculate_status_when_la_missing.rake diff --git a/lib/tasks/recalculate_status_when_la_missing.rake b/lib/tasks/recalculate_status_when_la_missing.rake new file mode 100644 index 000000000..16af29cc7 --- /dev/null +++ b/lib/tasks/recalculate_status_when_la_missing.rake @@ -0,0 +1,19 @@ +desc "Recalculates status for 2023 completed logs with missing LA" +task recalculate_status_missing_la: :environment do + # See reinfer_local_authority - this covers cases where postcode_full was not set that should have been returned to in progress + LettingsLog.filter_by_year(2023).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(2023).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