Browse Source
# Conflicts: # app/models/form/sales/questions/purchase_price.rbCLDC-4313-resolve-unhandled-errors-on-large-numbers-in-numeric-fields
68 changed files with 507 additions and 625 deletions
@ -1 +1,5 @@
|
||||
You have given us the details for 0 of the <%= log.hholdcount %> other people in the household |
||||
<% if log.form.start_year_2026_or_later? %> |
||||
You have given us the details for 1 of the <%= log.hholdcount %> people in the household |
||||
<% else %> |
||||
You have given us the details for 0 of the <%= log.hholdcount %> other people in the household |
||||
<% end %> |
||||
|
||||
@ -1 +1,5 @@
|
||||
You have given us the details for <%= log.joint_purchase? ? 0 : 1 %> of the <%= log.hholdcount %> other people in the household |
||||
<% if log.form.start_year_2026_or_later? %> |
||||
You have given us the details for 2 of the <%= log.hholdcount %> people in the household |
||||
<% else %> |
||||
You have given us the details for <%= log.joint_purchase? ? 0 : 1 %> of the <%= log.hholdcount %> other people in the household |
||||
<% end %> |
||||
|
||||
@ -1 +1,5 @@
|
||||
You have given us the details for <%= log.joint_purchase? ? 1 : 2 %> of the <%= log.hholdcount %> other people in the household |
||||
<% if log.form.start_year_2026_or_later? %> |
||||
You have given us the details for 3 of the <%= log.hholdcount %> people in the household |
||||
<% else %> |
||||
You have given us the details for <%= log.joint_purchase? ? 1 : 2 %> of the <%= log.hholdcount %> other people in the household |
||||
<% end %> |
||||
|
||||
@ -1 +1,5 @@
|
||||
You have given us the details for <%= log.joint_purchase? ? 2 : 3 %> of the <%= log.hholdcount %> other people in the household |
||||
<% if log.form.start_year_2026_or_later? %> |
||||
You have given us the details for 4 of the <%= log.hholdcount %> people in the household |
||||
<% else %> |
||||
You have given us the details for <%= log.joint_purchase? ? 2 : 3 %> of the <%= log.hholdcount %> other people in the household |
||||
<% end %> |
||||
|
||||
@ -1 +1,5 @@
|
||||
You have given us the details for <%= log.joint_purchase? ? 3 : 4 %> of the <%= log.hholdcount %> other people in the household |
||||
<% if log.form.start_year_2026_or_later? %> |
||||
You have given us the details for 5 of the <%= log.hholdcount %> people in the household |
||||
<% else %> |
||||
You have given us the details for <%= log.joint_purchase? ? 3 : 4 %> of the <%= log.hholdcount %> other people in the household |
||||
<% end %> |
||||
|
||||
@ -0,0 +1,34 @@
|
||||
desc "Deletes all logs in a given collection year and earlier. Note that this operation is PERMANENT and this will bypass callbacks/paper trail. Use only as instructed in a yearly cleanup task." |
||||
task :delete_logs_in_collection_year_and_earlier, %i[year] => :environment do |_task, args| |
||||
year = args[:year].to_i |
||||
|
||||
if year < 2020 |
||||
raise ArgumentError, "Year must be above 2020. Make sure you've written out the entire year" |
||||
end |
||||
|
||||
if year > Time.zone.now.year - 3 |
||||
raise ArgumentError, "Year cannot be the last 3 years, as these may contain visible logs" |
||||
end |
||||
|
||||
puts "Deleting Logs before #{year}" |
||||
|
||||
puts "Deleting Sales Logs in batches of 10000" |
||||
logs = SalesLog.filter_by_year_or_earlier(year) |
||||
|
||||
logs.in_batches(of: 10_000).each_with_index do |logs, i| |
||||
puts "Deleting batch #{i + 1}" |
||||
logs.delete_all |
||||
end |
||||
puts "Done deleting Sales Logs" |
||||
|
||||
puts "Deleting Lettings Logs in batches of 10000" |
||||
logs = LettingsLog.filter_by_year_or_earlier(year) |
||||
|
||||
logs.in_batches(of: 10_000).each_with_index do |logs, i| |
||||
puts "Deleting batch #{i + 1}" |
||||
logs.delete_all |
||||
end |
||||
puts "Done deleting Lettings Logs" |
||||
|
||||
puts "Done deleting Logs before #{year}" |
||||
end |
||||
@ -0,0 +1,11 @@
|
||||
desc "Rounds purchase price (the 'value' field) for sales logs in the database if not a whole number" |
||||
task round_value_for_2026_sales_logs: :environment do |
||||
logs = SalesLog.filter_by_year(2026).where("value % 1 != 0") |
||||
puts "Correcting #{logs.count} sales logs, #{logs.map(&:id)}" |
||||
|
||||
logs.find_each do |log| |
||||
log.update(value: log.value.round) |
||||
end |
||||
|
||||
puts "Done" |
||||
end |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue