diff --git a/CHANGELOG.md b/CHANGELOG.md index c78017d2a..670d5392d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +15.04.2015 + +* Added whois tasks, more info with rake -T whois + 02.04.2015 * Depricated DelayedJob, kill all running delayed jobs if needed diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index 1ca5dcd44..29d15fcb8 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -1,21 +1,15 @@ namespace :whois do - desc 'Regenerate Registry records and sync whois database' - task sync_all: :environment do - - end - - desc 'Regenerate whois records at Registry master database' - task generate: :environment do + desc 'Delete whois database data and import all from Registry (fast)' + task reset: :environment do start = Time.zone.now.to_f - print "-----> Update Registry whois records..." - Domain.included.find_each(batch_size: 100000).with_index do |d, index| - d.update_columns(whois_body: d.update_whois_body) - print '.' if index % 100 == 0 - end + print "-----> Reset whois database and sync..." + domains = Domain.pluck(:name, :whois_body) + Whois::Domain.delete_all + Whois::Domain.import([:name, :whois_body], domains) puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" end - desc 'Sync whois database' + desc 'Sync whois database without reset (slow)' task sync: :environment do start = Time.zone.now.to_f print "-----> Sync whois database..." @@ -25,4 +19,15 @@ namespace :whois do end puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" end + + desc 'Regenerate whois_body at Registry master database (slow)' + task generate: :environment do + start = Time.zone.now.to_f + print "-----> Update Registry records..." + Domain.included.find_each(batch_size: 100000).with_index do |d, index| + d.update_columns(whois_body: d.update_whois_body) + print '.' if index % 100 == 0 + end + puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" + end end