mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Merge branch 'story/115762063--show-historical-nested' into staging
# Conflicts: # app/models/domain.rb # app/views/admin/domains/partials/_version.haml # config/locales/en.yml
This commit is contained in:
commit
f69c4ef919
7 changed files with 155 additions and 86 deletions
|
@ -3,6 +3,7 @@ module Versions
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :version_loader
|
||||
has_paper_trail class_name: "#{model_name}Version"
|
||||
|
||||
# add creator and updator
|
||||
|
@ -55,4 +56,23 @@ module Versions
|
|||
domains.each(&:touch_with_version)
|
||||
end
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def all_versions_for(ids, time)
|
||||
ver_klass = paper_trail_version_class
|
||||
from_history = ver_klass.where(item_id: ids).
|
||||
order(:item_id).
|
||||
preceding(time + 1, true).
|
||||
select("distinct on (item_id) #{ver_klass.table_name}.*").
|
||||
map do |ver|
|
||||
o = new(ver.object)
|
||||
o.version_loader = ver
|
||||
ver.object_changes.to_h.each { |k, v| o[k]=v[-1] }
|
||||
o
|
||||
end
|
||||
not_in_history = where(id: (ids - from_history.map(&:id)))
|
||||
|
||||
from_history + not_in_history
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -746,6 +746,7 @@ class Domain < ActiveRecord::Base
|
|||
log[:dnskeys] = dnskey_ids
|
||||
log[:legal_documents]= [legal_document_id]
|
||||
log[:registrant] = [registrant_id]
|
||||
log[:dnskeys] = dnskeys_ids
|
||||
log
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue