mirror of
https://github.com/internetee/registry.git
synced 2025-05-19 18:59:38 +02:00
Story#104525318 - get states change timestamps
This commit is contained in:
parent
3c0e04beac
commit
df6e254cc6
2 changed files with 16 additions and 0 deletions
|
@ -79,5 +79,19 @@ module Legacy
|
|||
|
||||
map[state_id]
|
||||
end
|
||||
|
||||
|
||||
class << self
|
||||
def changes_dates_for domain_id
|
||||
sql = %Q{SELECT t_2.id, state.*
|
||||
FROM object_history t_2
|
||||
JOIN object_state state ON (t_2.historyid >= state.ohid_from
|
||||
AND (t_2.historyid <= state.ohid_to OR state.ohid_to IS NULL))
|
||||
AND t_2.id = state.object_id
|
||||
WHERE state.object_id=#{domain_id}
|
||||
ORDER BY t_2.historyid;}
|
||||
find_by_sql(sql).map{|e| e.attributes.values_at("valid_from", "valid_to") }.flatten.each_with_object({}){|e,h|h[e] = [self]}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -772,6 +772,8 @@ namespace :import do
|
|||
Legacy::DomainHistory.uniq.pluck(:id).each do |legacy_domain_id|
|
||||
# 1. add domain changes
|
||||
# 2. add states
|
||||
# compose hash of change time -> Object changes
|
||||
history = Legacy::ObjectState.changes_dates_for(legacy_domain_id)
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue