mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 12:08:27 +02:00
Story#104525318 - in domain history import match change records in historical order
This commit is contained in:
parent
df6e254cc6
commit
3e8309f818
3 changed files with 106 additions and 30 deletions
|
@ -5,5 +5,33 @@ module Legacy
|
|||
belongs_to :domain, foreign_key: :id
|
||||
belongs_to :history, foreign_key: :historyid
|
||||
has_one :object_history, foreign_key: :historyid, primary_key: :historyid
|
||||
|
||||
def get_current_domain_object(param)
|
||||
p "not implemented #{__method__}"
|
||||
end
|
||||
|
||||
def get_current_changes(param)
|
||||
p "not implemented #{__method__}"
|
||||
end
|
||||
|
||||
class << self
|
||||
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
|
||||
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]}
|
||||
|
||||
hash = {}
|
||||
find_by_sql(sql).each do |rec|
|
||||
hash[rec.valid_from.try(:to_time)] = [{id: rec.historyid, klass: self, param: :valid_from}] if rec.valid_from
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
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
|
||||
where dh.id=#{domain_id} and dh.historyid = #{rec_id} ;}
|
||||
find_by_sql(sql).first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue