111297422-job_and_method_update

This commit is contained in:
Stas 2016-01-26 14:36:09 +02:00
parent 8ed8a46046
commit a0fcd8be8b
4 changed files with 28 additions and 13 deletions

View file

@ -3,18 +3,23 @@ namespace :whois do
task regenerate: :environment do
start = Time.zone.now.to_f
@i = 0
print "-----> Regenerate Registry whois_records table and sync with whois server..."
ActiveRecord::Base.uncached do
puts "\n#{@i}"
Domain.included.find_in_batches(batch_size: 10000) do |batch|
batch.map(&:update_whois_record)
puts(@i += 10000)
GC.start
print "\n-----> Update domains whois_records"
Domain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:id), 'domain'
end
GC.start
UpdateWhoisRecordJob.enqueue WhoisRecord.find_each.map(&:id), 'domain'
print "\n-----> Update blocked domains whois_records"
BlockedDomain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:id), 'blocked'
end
print "\n-----> Update reserved domains whois_records"
ReservedDomain.find_in_batches.each do |group|
UpdateWhoisRecordJob.enqueue group.map(&:id), 'reserved'
end
end
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"