mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
module Legacy
|
|
class Domain < Db
|
|
self.table_name = :domain
|
|
|
|
belongs_to :object_registry, foreign_key: :id
|
|
belongs_to :object, foreign_key: :id
|
|
belongs_to :nsset, foreign_key: :nsset
|
|
# belongs_to :registrant, foreign_key: :registrant, primary_key: :legacy_id, class_name: '::Contact'
|
|
|
|
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
|
|
|
|
def self.new_registrar_cached old_id
|
|
@new_registrar_cache ||= {}
|
|
@new_registrar_cache[old_id] ||= ::Registrar.select(:id).find_by(legacy_id: old_id)
|
|
end
|
|
|
|
def self.new_api_user_cached old_id
|
|
@new_api_user_cache ||= {}
|
|
@new_api_user_cache[old_id] ||= Legacy::Domain.new_registrar_cached(old_id).try(:api_users).try(:first)
|
|
end
|
|
|
|
end
|
|
end
|