mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Merge branch 'master' into 115693873-whodunnit_empty
This commit is contained in:
commit
e23b5fc9cf
125 changed files with 2167 additions and 714 deletions
|
@ -68,25 +68,27 @@ class DomainCron
|
|||
marked
|
||||
end
|
||||
|
||||
def self.start_delete_period
|
||||
begin
|
||||
STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test?
|
||||
#doing nothing, deprecated
|
||||
|
||||
d = Domain.where('delete_at <= ?', Time.zone.now)
|
||||
marked = 0
|
||||
real = 0
|
||||
d.each do |domain|
|
||||
next unless domain.delete_candidateable?
|
||||
real += 1
|
||||
domain.statuses << DomainStatus::DELETE_CANDIDATE
|
||||
STDOUT << "#{Time.zone.now.utc} DomainCron.start_delete_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test?
|
||||
::PaperTrail.whodunnit = "cron - #{__method__}"
|
||||
domain.save(validate: false) and marked += 1
|
||||
end
|
||||
ensure # the operator should see what was accomplished
|
||||
STDOUT << "#{Time.zone.now.utc} - Finished setting delete_candidate - #{marked} out of #{real} successfully set\n" unless Rails.env.test?
|
||||
end
|
||||
marked
|
||||
def self.start_delete_period
|
||||
# begin
|
||||
# STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test?
|
||||
#
|
||||
# d = Domain.where('delete_at <= ?', Time.zone.now)
|
||||
# marked = 0
|
||||
# real = 0
|
||||
# d.each do |domain|
|
||||
# next unless domain.delete_candidateable?
|
||||
# real += 1
|
||||
# domain.statuses << DomainStatus::DELETE_CANDIDATE
|
||||
# STDOUT << "#{Time.zone.now.utc} DomainCron.start_delete_period: ##{domain.id} (#{domain.name})\n" unless Rails.env.test?
|
||||
# ::PaperTrail.whodunnit = "cron - #{__method__}"
|
||||
# domain.save(validate: false) and marked += 1
|
||||
# end
|
||||
# ensure # the operator should see what was accomplished
|
||||
# STDOUT << "#{Time.zone.now.utc} - Finished setting delete_candidate - #{marked} out of #{real} successfully set\n" unless Rails.env.test?
|
||||
# end
|
||||
# marked
|
||||
end
|
||||
|
||||
def self.destroy_delete_candidates
|
||||
|
@ -99,10 +101,23 @@ class DomainCron
|
|||
destroy_with_message x
|
||||
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test?
|
||||
|
||||
c += 1
|
||||
Domain.where('delete_at <= ?', Time.zone.now).each do |x|
|
||||
next unless x.delete_candidateable?
|
||||
|
||||
x.statuses << DomainStatus::DELETE_CANDIDATE
|
||||
|
||||
# If domain successfully saved, add it to delete schedule
|
||||
if x.save(validate: false)
|
||||
::PaperTrail.whodunnit = "cron - #{__method__}"
|
||||
DomainDeleteJob.enqueue(x.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now)
|
||||
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: job added by deleteCandidate status ##{x.id} (#{x.name})\n" unless Rails.env.test?
|
||||
c += 1
|
||||
end
|
||||
end
|
||||
|
||||
Domain.where('force_delete_at <= ?', Time.zone.now).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?
|
||||
::PaperTrail.whodunnit = "cron - #{__method__} case force_deleted_at"
|
||||
WhoisRecord.where(domain_id: x.id).destroy_all
|
||||
destroy_with_message x
|
||||
|
@ -110,7 +125,7 @@ class DomainCron
|
|||
c += 1
|
||||
end
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test?
|
||||
STDOUT << "#{Time.zone.now.utc} - Job destroy added for #{c} domains\n" unless Rails.env.test?
|
||||
end
|
||||
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue