mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Merge pull request #112 from internetee/113430903-delete_candidate_randomizer
113430903 delete candidate randomizer
This commit is contained in:
commit
eca211a014
3 changed files with 36 additions and 11 deletions
17
app/jobs/domain_delete_job.rb
Normal file
17
app/jobs/domain_delete_job.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class DomainDeleteJob < Que::Job
|
||||
|
||||
def run(domain_id)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
::PaperTrail.whodunnit = "job - #{self.class.name}"
|
||||
WhoisRecord.where(domain_id: domain.id).destroy_all
|
||||
|
||||
domain.destroy
|
||||
bye_bye = domain.versions.last
|
||||
domain.registrar.messages.create!(
|
||||
body: "#{I18n.t(:domain_deleted)}: #{domain.name}",
|
||||
attached_obj_id: bye_bye.id,
|
||||
attached_obj_type: bye_bye.class.to_s
|
||||
)
|
||||
end
|
||||
end
|
10
app/jobs/domain_set_delete_candidate_job.rb
Normal file
10
app/jobs/domain_set_delete_candidate_job.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
class DomainSetDeleteCandidateJob < Que::Job
|
||||
|
||||
def run(domain_id)
|
||||
domain = Domain.find(domain_id)
|
||||
domain.statuses << DomainStatus::DELETE_CANDIDATE
|
||||
::PaperTrail.whodunnit = "job - #{self.class.name}"
|
||||
domain.save(validate: false)
|
||||
DomainDeleteJob.enqueue(domain.id, run_at: rand(((24*60) - (DateTime.now.hour * 60 + DateTime.now.minute))).minutes.from_now)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue