Browse Source

Merge branch 'main' into BuGuidanceBackLinks

pull/2482/head
Rachael Booth 2 years ago committed by GitHub
parent
commit
f289b50918
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      lib/tasks/handle_unpended_logs.rake
  2. 19
      lib/tasks/recalculate_status_when_la_missing.rake

14
lib/tasks/handle_unpended_logs.rake

@ -115,8 +115,11 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, args|
affected_non_updated_duplicates.each do |d| affected_non_updated_duplicates.each do |d|
seen.add(d.id) seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of unaffected log(s)", unaffected_logs_reference] csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of unaffected log(s)", unaffected_logs_reference]
# rubocop:disable Style/Next
unless dry_run unless dry_run
d.discard! d.discarded_at = Time.zone.now
d.status = "deleted"
d.save!(validate: false)
end end
end end
next next
@ -134,7 +137,9 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, args|
seen.add(d.id) seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of log(s) which have been updated since being affected", updated_logs_reference] csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of log(s) which have been updated since being affected", updated_logs_reference]
unless dry_run unless dry_run
d.discard! d.discarded_at = Time.zone.now
d.status = "deleted"
d.save!(validate: false)
end end
end end
next next
@ -150,8 +155,11 @@ task :handle_unpended_logs, %i[perform_updates] => :environment do |_task, args|
seen.add(d.id) seen.add(d.id)
csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of more recently created affected log", latest_created.id] csv << [d.id, d.collection_start_year, d.status, d.owning_organisation_name, d.assigned_to_id, d.assigned_to.email, "Delete", "Log is a duplicate of more recently created affected log", latest_created.id]
unless dry_run unless dry_run
d.discard! d.discarded_at = Time.zone.now
d.status = "deleted"
d.save!(validate: false)
end end
# rubocop:enable Style/Next
end end
end end
end end

19
lib/tasks/recalculate_status_when_la_missing.rake

@ -0,0 +1,19 @@
desc "Recalculates status for 2023 completed logs with missing LA"
task recalculate_status_missing_la: :environment do
# See reinfer_local_authority - this covers cases where postcode_full was not set that should have been returned to in progress
LettingsLog.filter_by_year(2023).where(needstype: 1, la: nil, status: "completed").find_each do |log|
log.status = log.calculate_status
unless log.save
Rails.logger.info "Could not save changes to lettings log #{log.id}"
end
end
SalesLog.filter_by_year(2023).where(la: nil, status: "completed").find_each do |log|
log.status = log.calculate_status
unless log.save
Rails.logger.info "Could not save changes to sales log #{log.id}"
end
end
end
Loading…
Cancel
Save