mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 08:43:37 +02:00
Whois update updates server
This commit is contained in:
parent
3b009dc194
commit
d9b2e5880a
2 changed files with 11 additions and 10 deletions
|
@ -13,6 +13,8 @@ class WhoisRecord < ActiveRecord::Base
|
||||||
self.registrar_id = domain.registrar_id # for faster registrar updates
|
self.registrar_id = domain.registrar_id # for faster registrar updates
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after_save :update_whois_server
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def included
|
def included
|
||||||
includes(
|
includes(
|
||||||
|
@ -141,7 +143,6 @@ More information at http://internet.ee
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_whois_server
|
def update_whois_server
|
||||||
return logger.info "NO WHOIS NAME for whois record id: #{id}" if name.blank?
|
|
||||||
wd = Whois::Record.find_or_initialize_by(name: name)
|
wd = Whois::Record.find_or_initialize_by(name: name)
|
||||||
wd.body = body
|
wd.body = body
|
||||||
wd.json = json
|
wd.json = json
|
||||||
|
|
|
@ -16,15 +16,15 @@ namespace :whois do
|
||||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Delete whois database data and import from Registry master database (faster)'
|
# desc 'Delete whois database data and import from Registry master database (faster)'
|
||||||
task export: :environment do
|
# task export: :environment do
|
||||||
start = Time.zone.now.to_f
|
# start = Time.zone.now.to_f
|
||||||
print "-----> Delete whois database data and import from Registry whois_records table..."
|
# print "-----> Delete whois database data and import from Registry whois_records table..."
|
||||||
whois_records = WhoisRecord.pluck(:name, :body, :json)
|
# whois_records = WhoisRecord.pluck(:name, :body, :json)
|
||||||
Whois::Record.delete_all
|
# Whois::Record.delete_all
|
||||||
Whois::Record.import([:name, :body, :json], whois_records)
|
# Whois::Record.import([:name, :body, :json], whois_records)
|
||||||
puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
# puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
# end
|
||||||
|
|
||||||
namespace :schema do
|
namespace :schema do
|
||||||
desc 'Load whois schema into empty whois database'
|
desc 'Load whois schema into empty whois database'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue