mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 11:47:30 +02:00
Move #redemption_grace_period to interactor
This commit is contained in:
parent
849010b118
commit
d17e26c28b
4 changed files with 51 additions and 18 deletions
10
app/interactions/domains/redemption_grace_period/base.rb
Normal file
10
app/interactions/domains/redemption_grace_period/base.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Domains
|
||||
module RedemptionGracePeriod
|
||||
class Base < ActiveInteraction::Base
|
||||
def to_stdout(message)
|
||||
time = Time.zone.now.utc
|
||||
STDOUT << "#{time} - #{message}\n" unless Rails.env.test?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
module Domains
|
||||
module RedemptionGracePeriod
|
||||
class ProcessGracePeriod < Base
|
||||
object :domain,
|
||||
class: Domain
|
||||
|
||||
def execute
|
||||
domain.statuses << DomainStatus::SERVER_HOLD
|
||||
to_stdout(process_msg)
|
||||
domain.save(validate: false)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process_msg
|
||||
"start_redemption_grace_period: #{domain.id} (#{domain.name}) #{domain.changes}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
app/interactions/domains/redemption_grace_period/start.rb
Normal file
20
app/interactions/domains/redemption_grace_period/start.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Domains
|
||||
module RedemptionGracePeriod
|
||||
class Start < Base
|
||||
def execute
|
||||
to_stdout('Setting server_hold to domains')
|
||||
|
||||
::PaperTrail.request.whodunnit = "cron - #{self.class.name}"
|
||||
count = 0
|
||||
|
||||
Domain.outzone_candidates.each do |domain|
|
||||
next unless domain.server_holdable?
|
||||
|
||||
count += 1
|
||||
Domains::RedemptionGracePeriod::ProcessGracePeriod.run(domain: domain)
|
||||
end
|
||||
to_stdout("Successfully set server_hold to #{count} of domains")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,24 +8,7 @@ class DomainCron
|
|||
end
|
||||
|
||||
def self.start_redemption_grace_period
|
||||
STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test?
|
||||
|
||||
::PaperTrail.request.whodunnit = "cron - #{__method__}"
|
||||
|
||||
domains = Domain.outzone_candidates
|
||||
marked = 0
|
||||
real = 0
|
||||
|
||||
domains.each do |domain|
|
||||
next unless domain.server_holdable?
|
||||
real += 1
|
||||
domain.statuses << DomainStatus::SERVER_HOLD
|
||||
STDOUT << "#{Time.zone.now.utc} DomainCron.start_redemption_grace_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test?
|
||||
domain.save(validate: false) and marked += 1
|
||||
end
|
||||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{marked} of #{real} domains\n" unless Rails.env.test?
|
||||
marked
|
||||
Domains::RedemptionGracePeriod::Start.run!
|
||||
end
|
||||
|
||||
def self.start_client_hold
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue