Browse Source

Use find_each for task

pull/2453/head
Rachael Booth 2 years ago
parent
commit
6f8991fc31
  1. 5
      lib/tasks/fix_nil_letting_allocation_values.rake

5
lib/tasks/fix_nil_letting_allocation_values.rake

@ -1,11 +1,10 @@
desc "Infer nil letting allocation values as no" desc "Infer nil letting allocation values as no"
task fix_nil_letting_allocation_values: :environment do task fix_nil_letting_allocation_values: :environment do
logs = LettingsLog.where(cbl: nil) LettingsLog.where(cbl: nil)
.or(LettingsLog.where(chr: nil)) .or(LettingsLog.where(chr: nil))
.or(LettingsLog.where(cap: nil)) .or(LettingsLog.where(cap: nil))
.or(LettingsLog.filter_by_year(2024).where(accessible_register: nil)) .or(LettingsLog.filter_by_year(2024).where(accessible_register: nil))
.find_each do |log|
logs.each do |log|
next unless log.cbl.present? || log.chr.present? || log.cap.present? || log.accessible_register.present? || log.letting_allocation_unknown.present? next unless log.cbl.present? || log.chr.present? || log.cap.present? || log.accessible_register.present? || log.letting_allocation_unknown.present?
log.cbl = 0 if log.cbl.blank? log.cbl = 0 if log.cbl.blank?

Loading…
Cancel
Save