mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
added stdout to log file
This commit is contained in:
parent
8063d538a6
commit
0950361e0a
2 changed files with 59 additions and 5 deletions
|
@ -1,11 +1,37 @@
|
|||
class MigrateBeforeForceDeleteStatusesJob < ApplicationJob
|
||||
def perform
|
||||
logger.info 'Ran MigrateBeforeForceDeleteStatusesJob!'
|
||||
|
||||
domains = Domain.where.not(statuses_before_force_delete: nil)
|
||||
logger.info "Total domains are #{domains.count}"
|
||||
|
||||
interate_domain_in_batches(domains)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def interate_domain_in_batches(domains)
|
||||
count = 0
|
||||
|
||||
domains.find_in_batches do |domain_batches|
|
||||
count += domain_batches.count
|
||||
logger.info "Proccesing #{count} domains of #{domains.count}"
|
||||
domain_batches.each do |domain|
|
||||
migrate_data_to_statuses_history(domain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def migrate_data_to_statuses_history(domain)
|
||||
domain.force_delete_domain_statuses_history = domain.statuses_before_force_delete
|
||||
domain.save
|
||||
rescue StandardError => e
|
||||
logger.warn "#{domain.name} crashed!"
|
||||
logger.warn e.to_s
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger ||= Logger.new(Rails.root.join('log', 'migrate_before_force_delete_statuses.log'))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,37 @@
|
|||
class MigrateStatusesToDomainHistoryJob < ApplicationJob
|
||||
def perform
|
||||
logger.info 'Ran MigrateStatusesToDomainHistoryJob!'
|
||||
|
||||
domains = Domain.where(locked_by_registrant_at: nil)
|
||||
domains.each do |domain|
|
||||
logger.info "Total domains are #{domains.count}"
|
||||
|
||||
interate_domain_in_batches(domains)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def interate_domain_in_batches(domains)
|
||||
count = 0
|
||||
|
||||
domains.find_in_batches do |domain_batches|
|
||||
count += domain_batches.count
|
||||
logger.info "Proccesing #{count} domains of #{domains.count}"
|
||||
domain_batches.each do |domain|
|
||||
migrate_data_to_admin_store_field(domain)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def migrate_data_to_admin_store_field(domain)
|
||||
domain.admin_store_statuses_history = domain.statuses
|
||||
domain.save
|
||||
rescue StandardError => e
|
||||
logger.warn "#{domain.name} crashed!"
|
||||
logger.warn e.to_s
|
||||
raise e
|
||||
end
|
||||
|
||||
def logger
|
||||
@logger ||= Logger.new(Rails.root.join('log', 'migrate_statuses_to_domain_history.log'))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue