mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Updated cron log #2792
This commit is contained in:
parent
030f7a18b7
commit
86e01597a8
4 changed files with 45 additions and 18 deletions
|
@ -166,9 +166,19 @@ class Contact < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy_orphans
|
def destroy_orphans
|
||||||
logger.info "#{Time.zone.now.utc} - Destroying orphaned contacts\n"
|
STDOUT << "#{Time.zone.now.utc} - Destroying orphaned contacts\n" unless Rails.env.test?
|
||||||
count = find_orphans.destroy_all.count
|
|
||||||
logger.info "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n"
|
orphans = find_orphans
|
||||||
|
|
||||||
|
unless Rails.env.test?
|
||||||
|
orphans.each do |m|
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Contact.destroy_orphans: ##{m.id}\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
count = orphans.destroy_all.count
|
||||||
|
|
||||||
|
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{count} orphaned contacts\n" unless Rails.env.test?
|
||||||
end
|
end
|
||||||
|
|
||||||
def privs
|
def privs
|
||||||
|
|
|
@ -182,6 +182,8 @@ class Domain < ActiveRecord::Base
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop: disable Metrics/AbcSize
|
||||||
|
# rubocop: disable Metrics/CyclomaticComplexity
|
||||||
def clean_expired_pendings
|
def clean_expired_pendings
|
||||||
STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test?
|
||||||
|
|
||||||
|
@ -197,18 +199,24 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
count += 1
|
count += 1
|
||||||
domain.clean_pendings!
|
domain.clean_pendings!
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id}\n" unless Rails.env.test?
|
||||||
end
|
end
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test?
|
||||||
count
|
count
|
||||||
end
|
end
|
||||||
|
# rubocop: enable Metrics/AbcSize
|
||||||
|
# rubocop: enable Metrics/CyclomaticComplexity
|
||||||
|
|
||||||
|
# rubocop: disable Metrics/LineLength
|
||||||
def start_expire_period
|
def start_expire_period
|
||||||
STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test?
|
||||||
|
|
||||||
domains = Domain.where('valid_to <= ?', Time.zone.now)
|
domains = Domain.where('valid_to <= ?', Time.zone.now)
|
||||||
domains.each do |domain|
|
domains.each do |domain|
|
||||||
next unless domain.expirable?
|
next unless domain.expirable?
|
||||||
domain.set_expired!
|
domain.set_expired
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
|
||||||
|
domain.save(validate: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{domains.count} domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully expired #{domains.count} domains\n" unless Rails.env.test?
|
||||||
|
@ -218,12 +226,11 @@ class Domain < ActiveRecord::Base
|
||||||
STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test?
|
||||||
|
|
||||||
d = Domain.where('outzone_at <= ?', Time.zone.now)
|
d = Domain.where('outzone_at <= ?', Time.zone.now)
|
||||||
d.each do |x|
|
d.each do |domain|
|
||||||
next unless x.server_holdable?
|
next unless domain.server_holdable?
|
||||||
x.statuses << DomainStatus::SERVER_HOLD
|
domain.statuses << DomainStatus::SERVER_HOLD
|
||||||
# TODO: This should be managed by automatic_statuses
|
STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
|
||||||
x.statuses.delete(DomainStatus::OK)
|
domain.save
|
||||||
x.save
|
|
||||||
end
|
end
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test?
|
||||||
|
@ -233,11 +240,11 @@ class Domain < ActiveRecord::Base
|
||||||
STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test?
|
||||||
|
|
||||||
d = Domain.where('delete_at <= ?', Time.zone.now)
|
d = Domain.where('delete_at <= ?', Time.zone.now)
|
||||||
d.each do |x|
|
d.each do |domain|
|
||||||
x.statuses << DomainStatus::DELETE_CANDIDATE if x.delete_candidateable?
|
next unless domain.delete_candidateable?
|
||||||
# TODO: This should be managed by automatic_statuses
|
domain.statuses << DomainStatus::DELETE_CANDIDATE
|
||||||
x.statuses.delete(DomainStatus::OK)
|
STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} #{domain.changes}\n" unless Rails.env.test?
|
||||||
x.save
|
domain.save
|
||||||
end
|
end
|
||||||
|
|
||||||
return if Rails.env.test?
|
return if Rails.env.test?
|
||||||
|
@ -251,17 +258,20 @@ class Domain < ActiveRecord::Base
|
||||||
c = 0
|
c = 0
|
||||||
Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
|
Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x|
|
||||||
x.destroy
|
x.destroy
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id}\n" unless Rails.env.test?
|
||||||
c += 1
|
c += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
Domain.where('force_delete_at <= ?', Time.zone.now).each do |x|
|
Domain.where('force_delete_at <= ?', Time.zone.now).each do |x|
|
||||||
x.destroy
|
x.destroy
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id}\n" unless Rails.env.test?
|
||||||
c += 1
|
c += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test?
|
||||||
end
|
end
|
||||||
# rubocop:enable Rails/FindEach
|
# rubocop:enable Rails/FindEach
|
||||||
|
# rubocop: enable Metrics/LineLength
|
||||||
end
|
end
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
|
|
|
@ -45,6 +45,12 @@ class Invoice < ActiveRecord::Base
|
||||||
'due_date < ? AND cancelled_at IS NULL', cr_at
|
'due_date < ? AND cancelled_at IS NULL', cr_at
|
||||||
)
|
)
|
||||||
|
|
||||||
|
unless Rails.env.test?
|
||||||
|
invoices.each do |m|
|
||||||
|
STDOUT << "#{Time.zone.now.utc} Invoice.cancel_overdue_invoices: ##{m.id}\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
count = invoices.update_all(cancelled_at: Time.zone.now)
|
count = invoices.update_all(cancelled_at: Time.zone.now)
|
||||||
|
|
||||||
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n" unless Rails.env.test?
|
STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} overdue invoices\n" unless Rails.env.test?
|
||||||
|
|
|
@ -24,9 +24,10 @@ every :day, at: '12:10am' do
|
||||||
runner 'Invoice.cancel_overdue_invoices'
|
runner 'Invoice.cancel_overdue_invoices'
|
||||||
end
|
end
|
||||||
|
|
||||||
every :day, at: '12:15am' do
|
# TODO
|
||||||
runner 'Domain.expire_domains'
|
# every :day, at: '12:15am' do
|
||||||
end
|
# runner 'Domain.expire_domains'
|
||||||
|
# end
|
||||||
|
|
||||||
every :day, at: '12:20am' do
|
every :day, at: '12:20am' do
|
||||||
runner 'Domain.clean_expired_pendings'
|
runner 'Domain.clean_expired_pendings'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue