mirror of
https://github.com/internetee/registry.git
synced 2025-07-04 18:23:35 +02:00
Story#108521790 - add admin contacts relation to domain history
This commit is contained in:
parent
33ee6f6256
commit
8dfb62151d
3 changed files with 22 additions and 2 deletions
5
app/models/legacy/domain_contact_map_history.rb
Normal file
5
app/models/legacy/domain_contact_map_history.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module Legacy
|
||||
class DomainContactMapHistory < Db
|
||||
self.table_name = :domain_contact_map_history
|
||||
end
|
||||
end
|
|
@ -8,13 +8,14 @@ module Legacy
|
|||
belongs_to :domain, foreign_key: :id
|
||||
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
|
||||
|
||||
def get_current_domain_object(time, change_param)
|
||||
x = self
|
||||
{
|
||||
name: SimpleIDN.to_unicode(x.object_registry.name.try(:strip)),
|
||||
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),
|
||||
valid_from: x.object_registry.try(:crdate),
|
||||
valid_to: x.exdate,
|
||||
|
@ -34,6 +35,15 @@ module Legacy
|
|||
}
|
||||
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
|
||||
def changes_dates_for domain_id
|
||||
sql = %Q{SELECT dh.*, valid_from
|
||||
|
|
|
@ -129,7 +129,12 @@ namespace :import do
|
|||
object: last_changes,
|
||||
object_changes: changes,
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue