Remove unused whois_records.body DB column

Part of https://github.com/internetee/rest-whois/issues/131
This commit is contained in:
Artur Beljajev 2018-11-08 00:44:19 +02:00
parent dea84915b5
commit 1a1c3c7d85
8 changed files with 1 additions and 127 deletions

View file

@ -25,18 +25,11 @@ class BlockedDomain < ActiveRecord::Base
wr = Whois::Record.find_or_initialize_by(name: name)
wr.json = @json = generate_json # we need @json to bind to class
wr.body = generate_body
wr.save
end
alias_method :update_whois_record, :generate_data
def generate_body
template = Rails.root.join("app/views/for_models/whois_other.erb".freeze)
ERB.new(template.read, nil, "-").result(binding)
end
def generate_json
h = HashWithIndifferentAccess.new
h[:name] = self.name

View file

@ -51,17 +51,10 @@ class ReservedDomain < ActiveRecord::Base
wr = Whois::Record.find_or_initialize_by(name: name)
wr.json = @json = generate_json # we need @json to bind to class
wr.body = generate_body
wr.save
end
alias_method :update_whois_record, :generate_data
def generate_body
template = Rails.root.join("app/views/for_models/whois_other.erb".freeze)
ERB.new(template.read, nil, "-").result(binding)
end
def generate_json
h = HashWithIndifferentAccess.new
h[:name] = self.name

View file

@ -3,7 +3,7 @@ class WhoisRecord < ActiveRecord::Base
belongs_to :domain
belongs_to :registrar
validates :domain, :name, :body, :json, presence: true
validates :domain, :name, :json, presence: true
before_validation :populate
after_save :update_whois_server
@ -87,23 +87,15 @@ class WhoisRecord < ActiveRecord::Base
h
end
def generated_body
template_name = domain.discarded? ? 'whois_discarded.erb' : 'whois.erb'
template = Rails.root.join("app/views/for_models/#{template_name}".freeze)
ERB.new(template.read, nil, "-").result(binding)
end
def populate
return if domain_id.blank?
self.json = generated_json
self.body = generated_body
self.name = json['name']
self.registrar_id = domain.registrar_id if domain # for faster registrar updates
end
def update_whois_server
wd = Whois::Record.find_or_initialize_by(name: name)
wd.body = body
wd.json = json
wd.save
end