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.
25 lines
918 B
25 lines
918 B
9 months ago
|
desc "Set duplicate references for sales and lettings logs"
|
||
|
task set_duplicate_references: :environment do
|
||
|
SalesLog.filter_by_year(2023).duplicate_sets.each do |duplicate_set|
|
||
|
duplicate_set_id = SalesLog.maximum(:duplicate_set_id).to_i + 1
|
||
|
next if duplicate_set.any? { |_log_id| SalesLog.exists?(duplicate_set_id:) }
|
||
|
|
||
|
duplicate_set.each do |log_id|
|
||
|
log = SalesLog.find(log_id)
|
||
|
log.duplicate_set_id = duplicate_set_id
|
||
|
log.save!(touch: false, validate: false)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
LettingsLog.filter_by_year(2023).duplicate_sets.each do |duplicate_set|
|
||
|
duplicate_set_id = LettingsLog.maximum(:duplicate_set_id).to_i + 1
|
||
|
next if duplicate_set.any? { |_log_id| LettingsLog.exists?(duplicate_set_id:) }
|
||
|
|
||
|
duplicate_set.each do |log_id|
|
||
|
log = LettingsLog.find(log_id)
|
||
|
log.duplicate_set_id = duplicate_set_id
|
||
|
log.save!(touch: false, validate: false)
|
||
|
end
|
||
|
end
|
||
|
end
|