Refactor force delete procedure

- Change `domains.force_delete_at` database column type to date,
rename to `force_delete_date`
- Save `force_delete_date` in application timezone
- Improve tests

Fixes #812, #253
This commit is contained in:
Artur Beljajev 2019-03-22 17:52:09 +02:00
parent f35b2dc36c
commit 5107d2d3a9
20 changed files with 62 additions and 33 deletions

View file

@ -84,7 +84,7 @@ class DomainCron
c = 0
Domain.where('force_delete_at <= ?', Time.zone.now.end_of_day.utc).each do |x|
Domain.where('force_delete_date <= ?', Time.zone.now.end_of_day.utc).each do |x|
DomainDeleteJob.enqueue(x.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now)
STDOUT << "#{Time.zone.now.utc} DomainCron.destroy_delete_candidates: job added by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test?
c += 1