Story#108521790 - add admin contacts relation to domain history

This commit is contained in:
Vladimir Krylov 2015-12-10 12:52:17 +02:00
parent 33ee6f6256
commit 8dfb62151d
3 changed files with 22 additions and 2 deletions

View file

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

View file

@ -8,13 +8,14 @@ module Legacy
belongs_to :domain, foreign_key: :id belongs_to :domain, foreign_key: :id
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
def get_current_domain_object(time, change_param) def get_current_domain_object(time, change_param)
x = self x = self
{ {
name: SimpleIDN.to_unicode(x.object_registry.name.try(:strip)), name: SimpleIDN.to_unicode(x.object_registry.name.try(:strip)),
registrar_id: ::Registrar.find_by(legacy_id: x.object_history.try(:clid)).try(:id), registrar_id: ::Registrar.find_by(legacy_id: x.object_history.try(:clid)).try(:id),
registrant_id: ::Contact.find_by(legacy_id: x.registrant).try(:id), registrant_id: new_registrant_id,
registered_at: x.object_registry.try(:crdate), registered_at: x.object_registry.try(:crdate),
valid_from: x.object_registry.try(:crdate), valid_from: x.object_registry.try(:crdate),
valid_to: x.exdate, valid_to: x.exdate,
@ -34,6 +35,15 @@ module Legacy
} }
end end
def get_admin_contact_new_ids
c_ids = domain_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)
end
class << self class << self
def changes_dates_for domain_id def changes_dates_for domain_id
sql = %Q{SELECT dh.*, valid_from sql = %Q{SELECT dh.*, valid_from

View file

@ -129,7 +129,12 @@ namespace :import do
object: last_changes, object: last_changes,
object_changes: changes, object_changes: changes,
created_at: time, created_at: time,
children: {} children: {
admin_contacts: [responder.get_admin_contact_new_ids],
tech_contacts: [],
nameservers: [],
registrant: [responder.new_registrant_id]
}
) )
last_changes = new_attrs last_changes = new_attrs