From b6f3c2d8ad053375b9135f09838e928a475e2ffe Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Fri, 7 Jun 2024 12:10:51 +0100 Subject: [PATCH] CLDC-3463: Use find_each in update task to avoid memory problems (#2455) --- lib/tasks/recalculate_vacdays.rake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tasks/recalculate_vacdays.rake b/lib/tasks/recalculate_vacdays.rake index 38aa98f9b..c83f58870 100644 --- a/lib/tasks/recalculate_vacdays.rake +++ b/lib/tasks/recalculate_vacdays.rake @@ -1,7 +1,6 @@ desc "Recalculate vacdays after bugfix for daylight savings time changes" task recalculate_vacdays: :environment do - logs = LettingsLog.where.not(vacdays: nil) - logs.each do |log| + LettingsLog.where.not(vacdays: nil).find_each do |log| Rails.logger.log("Log #{log.id}") recalculated_vacdays = log.send(:property_vacant_days) next if recalculated_vacdays == log.vacdays