Skip to content

Commit

Permalink
Remove unused whois_records.body DB column
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Dec 3, 2018
1 parent dea8491 commit 491fab9
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 107 deletions.
7 changes: 0 additions & 7 deletions app/models/blocked_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ def generate_data

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
Expand Down
7 changes: 0 additions & 7 deletions app/models/reserved_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,10 @@ def generate_data

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
Expand Down
10 changes: 1 addition & 9 deletions app/models/whois_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -87,23 +87,15 @@ def generate_json
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
Expand Down
67 changes: 0 additions & 67 deletions app/views/for_models/whois.erb

This file was deleted.

8 changes: 0 additions & 8 deletions app/views/for_models/whois_discarded.erb

This file was deleted.

8 changes: 0 additions & 8 deletions app/views/for_models/whois_other.erb

This file was deleted.

1 change: 0 additions & 1 deletion test/fixtures/whois_records.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
shop:
name: shop.test
domain: shop
body: WHOIS text
json:
name: shop.test

0 comments on commit 491fab9

Please sign in to comment.