From 50e01d7bcc046be490f7f46012a78c07ff57755e Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 7 Apr 2026 16:01:16 +0100 Subject: [PATCH] fixup! CLDC-4298: Add a rake task to round value values remove redundant query update desc remove unneeded comment --- lib/tasks/round_value_for_2026_sales_logs.rake | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/tasks/round_value_for_2026_sales_logs.rake b/lib/tasks/round_value_for_2026_sales_logs.rake index 31447a5f7..c0f584799 100644 --- a/lib/tasks/round_value_for_2026_sales_logs.rake +++ b/lib/tasks/round_value_for_2026_sales_logs.rake @@ -1,10 +1,9 @@ -desc "Rounds and value for sales logs in the database if they are not a whole number" +desc "Rounds purchase price (the 'value' field) for sales logs in the database if not a whole number" task round_value_for_2026_sales_logs: :environment do - ids = SalesLog.filter_by_year(2026).where("value % 1 != 0").pluck(:id) - puts "Correcting #{ids.count} sales logs, #{ids}" + logs = SalesLog.filter_by_year(2026).where("value % 1 != 0") + puts "Correcting #{logs.count} sales logs, #{logs.map(&:id)}" - # find all values of mortgage that are not a whole number - SalesLog.filter_by_year(2026).where("value % 1 != 0").find_each do |log| + logs.find_each do |log| log.update(value: log.value.round) end