Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

16 lines
577 B

desc "Recalculate vacdays after bugfix for daylight savings time changes"
task recalculate_vacdays: :environment do
LettingsLog.where.not(vacdays: nil).find_each do |log|
Rails.logger.info("Log #{log.id}")
recalculated_vacdays = log.send(:property_vacant_days)
next if recalculated_vacdays == log.vacdays
log.vacdays = recalculated_vacdays
next if log.save
Rails.logger.info("Log #{log.id} could not be saved, saving updated vacdays without validation")
log.reload
log.vacdays = recalculated_vacdays
log.save!(validate: false)
end
end