Story#108521790 - add tech contacts relation to domain history

This commit is contained in:
Vladimir Krylov 2015-12-10 13:53:55 +02:00
parent 8dfb62151d
commit 112dac9e7c
4 changed files with 13 additions and 2 deletions

View file

@ -807,8 +807,8 @@ class Domain < ActiveRecord::Base
log[:admin_contacts] = admin_contact_ids log[:admin_contacts] = admin_contact_ids
log[:tech_contacts] = tech_contact_ids log[:tech_contacts] = tech_contact_ids
log[:nameservers] = nameserver_ids log[:nameservers] = nameserver_ids
log[:dnskeys] = dnskey_ids
log[:registrant] = [registrant_id] log[:registrant] = [registrant_id]
log[:domain_statuses] = domain_status_ids
log log
end end

View file

@ -9,6 +9,7 @@ module Legacy
belongs_to :history, foreign_key: :historyid belongs_to :history, foreign_key: :historyid
has_one :object_history, foreign_key: :historyid, primary_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 :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) def get_current_domain_object(time, change_param)
x = self x = self
@ -39,6 +40,10 @@ module Legacy
c_ids = domain_contact_map_histories.pluck(:contactid).join("','") c_ids = domain_contact_map_histories.pluck(:contactid).join("','")
DomainVersion.where("object->>'legacy_id' IN ('#{c_ids}')").uniq.pluck(:item_id) DomainVersion.where("object->>'legacy_id' IN ('#{c_ids}')").uniq.pluck(:item_id)
end 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 def new_registrant_id
@new_registrant_id ||= ::Contact.find_by(legacy_id: registrant).try(:id) @new_registrant_id ||= ::Contact.find_by(legacy_id: registrant).try(:id)

View file

@ -0,0 +1,5 @@
module Legacy
class NssetContactMapHistory < Db
self.table_name = :nsset_contact_map_history
end
end

View file

@ -131,8 +131,9 @@ namespace :import do
created_at: time, created_at: time,
children: { children: {
admin_contacts: [responder.get_admin_contact_new_ids], admin_contacts: [responder.get_admin_contact_new_ids],
tech_contacts: [], tech_contacts: [responder.get_tech_contact_new_ids],
nameservers: [], nameservers: [],
dnskeys: [],
registrant: [responder.new_registrant_id] registrant: [responder.new_registrant_id]
} }
) )