From 112dac9e7c1f13c42bb28a822b1ad7ee561b21fa Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 10 Dec 2015 13:53:55 +0200 Subject: [PATCH] Story#108521790 - add tech contacts relation to domain history --- app/models/domain.rb | 2 +- app/models/legacy/domain_history.rb | 5 +++++ app/models/legacy/nsset_contact_map_history.rb | 5 +++++ lib/tasks/import_history.rake | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 app/models/legacy/nsset_contact_map_history.rb diff --git a/app/models/domain.rb b/app/models/domain.rb index bb7a8356c..a76de9e4a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -807,8 +807,8 @@ class Domain < ActiveRecord::Base log[:admin_contacts] = admin_contact_ids log[:tech_contacts] = tech_contact_ids log[:nameservers] = nameserver_ids + log[:dnskeys] = dnskey_ids log[:registrant] = [registrant_id] - log[:domain_statuses] = domain_status_ids log end diff --git a/app/models/legacy/domain_history.rb b/app/models/legacy/domain_history.rb index 7a81db413..d127e15c6 100644 --- a/app/models/legacy/domain_history.rb +++ b/app/models/legacy/domain_history.rb @@ -9,6 +9,7 @@ module Legacy belongs_to :history, foreign_key: :historyid has_one :object_history, foreign_key: :historyid, primary_key: :historyid has_many :domain_contact_map_histories, foreign_key: :historyid, primary_key: :historyid + has_many :nsset_contact_map_histories, foreign_key: :historyid, primary_key: :historyid def get_current_domain_object(time, change_param) x = self @@ -39,6 +40,10 @@ module Legacy c_ids = domain_contact_map_histories.pluck(:contactid).join("','") DomainVersion.where("object->>'legacy_id' IN ('#{c_ids}')").uniq.pluck(:item_id) end + def get_tech_contact_new_ids + c_ids = nsset_contact_map_histories.pluck(:contactid).join("','") + DomainVersion.where("object->>'legacy_id' IN ('#{c_ids}')").uniq.pluck(:item_id) + end def new_registrant_id @new_registrant_id ||= ::Contact.find_by(legacy_id: registrant).try(:id) diff --git a/app/models/legacy/nsset_contact_map_history.rb b/app/models/legacy/nsset_contact_map_history.rb new file mode 100644 index 000000000..ffcb74793 --- /dev/null +++ b/app/models/legacy/nsset_contact_map_history.rb @@ -0,0 +1,5 @@ +module Legacy + class NssetContactMapHistory < Db + self.table_name = :nsset_contact_map_history + end +end diff --git a/lib/tasks/import_history.rake b/lib/tasks/import_history.rake index bf12e3e18..ba810b4ae 100644 --- a/lib/tasks/import_history.rake +++ b/lib/tasks/import_history.rake @@ -131,8 +131,9 @@ namespace :import do created_at: time, children: { admin_contacts: [responder.get_admin_contact_new_ids], - tech_contacts: [], + tech_contacts: [responder.get_tech_contact_new_ids], nameservers: [], + dnskeys: [], registrant: [responder.new_registrant_id] } )