mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Story#108521790 first scratch to get domain real historical object
This commit is contained in:
parent
3e8309f818
commit
f5a3e51e69
2 changed files with 28 additions and 6 deletions
|
@ -1,13 +1,36 @@
|
||||||
module Legacy
|
module Legacy
|
||||||
class DomainHistory < Db
|
class DomainHistory < Db
|
||||||
self.table_name = :domain_history
|
self.table_name = :domain_history
|
||||||
|
self.primary_key = :id
|
||||||
|
|
||||||
|
belongs_to :object_registry, foreign_key: :id
|
||||||
|
belongs_to :object, foreign_key: :id
|
||||||
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
|
||||||
|
|
||||||
def get_current_domain_object(param)
|
def get_current_domain_object(change_param)
|
||||||
p "not implemented #{__method__}"
|
x = self
|
||||||
|
{
|
||||||
|
name: SimpleIDN.to_unicode(x.object_registry.name.try(:strip)),
|
||||||
|
registrar_id: Registrar.find_by(legacy_id: x.object.try(:clid)).try(:id),
|
||||||
|
registered_at: x.object_registry.try(:crdate),
|
||||||
|
valid_from: x.object_registry.try(:crdate),
|
||||||
|
valid_to: x.exdate,
|
||||||
|
auth_info: x.object.authinfopw.try(:strip),
|
||||||
|
created_at: x.object_registry.try(:crdate),
|
||||||
|
updated_at: x.object.read_attribute(:update).nil? ? x.object_registry.try(:crdate) : x.object.read_attribute(:update),
|
||||||
|
name_dirty: x.object_registry.name.try(:strip),
|
||||||
|
name_puny: SimpleIDN.to_ascii(x.object_registry.name.try(:strip)),
|
||||||
|
period: 1,
|
||||||
|
period_unit: 'y',
|
||||||
|
creator_str: x.object_registry.try(:registrar).try(:name),
|
||||||
|
updator_str: x.object.try(:registrar).try(:name) ? x.object.try(:registrar).try(:name) : x.object_registry.try(:registrar).try(:name),
|
||||||
|
legacy_id: x.id,
|
||||||
|
legacy_registrar_id: x.object_registry.try(:crid),
|
||||||
|
legacy_registrant_id: x.registrant,
|
||||||
|
statuses: x.states
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_current_changes(param)
|
def get_current_changes(param)
|
||||||
|
@ -16,7 +39,7 @@ module Legacy
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def changes_dates_for domain_id
|
def changes_dates_for domain_id
|
||||||
sql = %Q{SELECT dh.*, valid_from--, extract(epoch from h.valid_from) valid_from_unix, extract(epoch from h.valid_to) valid_to_unix
|
sql = %Q{SELECT dh.*, valid_from
|
||||||
FROM domain_history dh JOIN history h ON dh.historyid=h.id where dh.id=#{domain_id};}
|
FROM domain_history dh JOIN history h ON dh.historyid=h.id where dh.id=#{domain_id};}
|
||||||
# find_by_sql(sql).map{|e| e.attributes.values_at("valid_from") }.flatten.each_with_object({}){|e,h|h[e.try(:to_f)] = [self]}
|
# find_by_sql(sql).map{|e| e.attributes.values_at("valid_from") }.flatten.each_with_object({}){|e,h|h[e.try(:to_f)] = [self]}
|
||||||
|
|
||||||
|
@ -28,7 +51,8 @@ module Legacy
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_record_at domain_id, rec_id
|
def get_record_at domain_id, rec_id
|
||||||
sql = %Q{SELECT dh.*, h.valid_from, h.valid_to from domain_history dh JOIN history h ON dh.historyid=h.id
|
sql = %Q{SELECT dh.*, h.valid_from, h.valid_to
|
||||||
|
from domain_history dh JOIN history h ON dh.historyid=h.id
|
||||||
where dh.id=#{domain_id} and dh.historyid = #{rec_id} ;}
|
where dh.id=#{domain_id} and dh.historyid = #{rec_id} ;}
|
||||||
find_by_sql(sql).first
|
find_by_sql(sql).first
|
||||||
end
|
end
|
||||||
|
|
|
@ -789,8 +789,6 @@ namespace :import do
|
||||||
keys = history.keys.compact.sort
|
keys = history.keys.compact.sort
|
||||||
i = 0
|
i = 0
|
||||||
keys.each_with_index do |time|
|
keys.each_with_index do |time|
|
||||||
|
|
||||||
p time
|
|
||||||
history[time].each do |orig_history_klass|
|
history[time].each do |orig_history_klass|
|
||||||
event = :update
|
event = :update
|
||||||
event = :create if i == 0
|
event = :create if i == 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue