From e292ec3931d56f041131c8930b46d82e7cd54176 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 31 Mar 2026 14:50:14 +0100 Subject: [PATCH] CLDC-4313: Add a rake task to correct logs --- ...correct_value_and_mortgage_for_2026_sales_logs.rake | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/tasks/correct_value_and_mortgage_for_2026_sales_logs.rake diff --git a/lib/tasks/correct_value_and_mortgage_for_2026_sales_logs.rake b/lib/tasks/correct_value_and_mortgage_for_2026_sales_logs.rake new file mode 100644 index 000000000..4e3919ce5 --- /dev/null +++ b/lib/tasks/correct_value_and_mortgage_for_2026_sales_logs.rake @@ -0,0 +1,10 @@ +desc "Clears mortgage and value values for sales logs in the database if they are over 999,999" +task correct_value_and_mortgage_for_2026_sales_logs: :environment do + ids = SalesLog.filter_by_year(2026).where("mortgage > 999999").pluck(:id) + SalesLog.filter_by_year(2026).where("value > 999999").pluck(:id).uniq + puts "Correcting #{ids.count} sales logs, #{ids}" + + SalesLog.filter_by_year(2026).where("mortgage > 999999").update!(mortgage: nil) + SalesLog.filter_by_year(2026).where("value > 999999").update!(value: nil) + + puts "Done" +end