Story#104525318 - cleanup import code

This commit is contained in:
Vladimir Krylov 2015-11-20 14:43:34 +02:00
parent e11c1b5d20
commit 3c0e04beac
3 changed files with 35 additions and 23 deletions

View file

@ -7,11 +7,23 @@ module Legacy
belongs_to :nsset, foreign_key: :nsset
# belongs_to :registrant, foreign_key: :registrant, primary_key: :legacy_id, class_name: '::Contact'
has_many :object_states, -> { where('valid_to IS NULL') }, foreign_key: :object_id
has_many :object_states, foreign_key: :object_id
has_many :dnskeys, foreign_key: :keysetid, primary_key: :keyset
has_many :domain_contact_maps, foreign_key: :domainid
has_many :nsset_contact_maps, foreign_key: :nssetid, primary_key: :nsset
has_many :domain_histories, foreign_key: :id
alias_method :history, :domain_histories
def new_states
domain_statuses = []
object_states.valid.each do |state|
next if state.name.blank?
domain_statuses << state.name
end
# OK status is default
domain_statuses << DomainStatus::OK if domain_statuses.empty?
end
end
end

View file

@ -2,6 +2,8 @@ module Legacy
class ObjectState < Db
self.table_name = :object_state
scope :valid, -> { where('valid_to IS NULL') }
# legacy values. Just for log
# 2 => "serverRenewProhibited",
# 5 => "serverOutzoneManual",