mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 23:42:04 +02:00
Refactored whois_body to whois_record
This commit is contained in:
parent
db81a9e7bc
commit
a0c880151b
10 changed files with 68 additions and 46 deletions
|
@ -1,10 +1,10 @@
|
|||
namespace :whois do
|
||||
desc 'Regenerate whois_body and whois_json at Registry master database (slow)'
|
||||
desc 'Regenerate whois records at Registry master database (slow)'
|
||||
task regenerate: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
print "-----> Regenerate whois_body and whois_json at Registry master database..."
|
||||
print "-----> Regenerate whois records at Registry master database..."
|
||||
Domain.included.find_each(batch_size: 50000).with_index do |d, index|
|
||||
d.update_whois_body
|
||||
d.update_whois_record
|
||||
print '.' if index % 100 == 0
|
||||
end
|
||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
|
@ -14,14 +14,14 @@ namespace :whois do
|
|||
task export: :environment do
|
||||
start = Time.zone.now.to_f
|
||||
print "-----> Delete whois database data and sync with Registry master database..."
|
||||
whois_bodies = WhoisBody.pluck(:name, :whois_body, :whois_json)
|
||||
Whois::Domain.delete_all
|
||||
Whois::Domain.import([:name, :whois_body, :whois_json], whois_bodies)
|
||||
whois_records = WhoisRecord.pluck(:name, :body, :json)
|
||||
Whois::Record.delete_all
|
||||
Whois::Record.import([:name, :body, :json], whois_records)
|
||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||
end
|
||||
|
||||
namespace :schema do
|
||||
desc 'Load whois schema'
|
||||
desc 'Load whois schema into empty whois database'
|
||||
task load: [:environment] do
|
||||
whois_db = "whois_#{Rails.env}"
|
||||
begin
|
||||
|
@ -37,5 +37,18 @@ namespace :whois do
|
|||
puts "\n#{e}"
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Force whois schema into exsisting whois database'
|
||||
task force_load: [:environment] do
|
||||
whois_db = "whois_#{Rails.env}"
|
||||
begin
|
||||
puts "\n------------------------ #{whois_db} schema loading ------------------------------\n"
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(whois_db.to_sym)
|
||||
load("#{Rails.root}/db/#{schema_file(whois_db)}")
|
||||
rescue => e
|
||||
puts "\n#{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue