mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 02:09:39 +02:00
119 lines
4.1 KiB
Ruby
119 lines
4.1 KiB
Ruby
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",
|
|
# 6 => "serverInzoneManual",
|
|
# 7 => "serverBlocked",
|
|
# 8 => "expirationWarning",
|
|
# 9 => "expired",
|
|
# 10 => "unguarded",
|
|
# 11 => "validationWarning1",
|
|
# 12 => "validationWarning2",
|
|
# 13 => "notValidated",
|
|
# 14 => "nssetMissing",
|
|
# 15 => "outzone",
|
|
# 18 => "serverRegistrantChangeProhibited",
|
|
# 19 => "deleteWarning",
|
|
# 20 => "outzoneUnguarded",
|
|
# 1 => "serverDeleteProhibited",
|
|
# 3 => "serverTransferProhibited",
|
|
# 4 => "serverUpdateProhibited",
|
|
# 16 => "linked",
|
|
# 17 => "deleteCandidate",
|
|
# 21 => "forceDelete"
|
|
|
|
# new values
|
|
STATE_NAMES = {
|
|
2 => "serverRenewProhibited",
|
|
5 => "serverHold",
|
|
6 => "serverManualInzone",
|
|
# 7 => "serverBlocked",
|
|
9 => "expired",
|
|
# 11 => "validationWarning1",
|
|
# 13 => "notValidated",
|
|
14 => "inactive",
|
|
15 => "serverHold",
|
|
18 => "serverRegistrantChangeProhibited",
|
|
1 => "serverDeleteProhibited",
|
|
3 => "serverTransferProhibited",
|
|
4 => "serverUpdateProhibited",
|
|
16 => "linked",
|
|
17 => "deleteCandidate", # grupistaatus
|
|
21 => "serverForceDelete" # grupistaatus
|
|
}.freeze
|
|
|
|
|
|
def name
|
|
STATE_NAMES[state_id]
|
|
end
|
|
|
|
def desc
|
|
map = {
|
|
1 => "Delete prohibited",
|
|
2 => "Registration renew prohibited",
|
|
3 => "Sponsoring registrar change prohibited",
|
|
4 => "Update prohibited",
|
|
7 => "Domain blocked",
|
|
8 => "Expires within 30 days",
|
|
9 => "Expired",
|
|
10 => "Domain is 30 days after expiration",
|
|
11 => "Validation of domain expire in 30 days",
|
|
12 => "Validation of domain expire in 15 days",
|
|
13 => "Domain not validated",
|
|
14 => "Domain has not associated nsset",
|
|
15 => "Domain is not generated into zone",
|
|
16 => "Has relation to other records in registry",
|
|
17 => "Object is going to be deleted",
|
|
18 => "Registrant change prohibited",
|
|
19 => "Domain will be deleted in 11 days",
|
|
20 => "Domain is out of zone after 30 days from expiration",
|
|
21 => "Domain is forced to delete",
|
|
5 => "Domain is administratively kept out of zone",
|
|
6 => "Domain is administratively kept in zone"
|
|
}
|
|
|
|
map[state_id]
|
|
end
|
|
|
|
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 distinct t_2.id, state.id state_dot_id, state.*,
|
|
extract(epoch from valid_from) valid_from_unix, extract(epoch from valid_to) valid_to_unix
|
|
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};}
|
|
hash = {}
|
|
find_by_sql(sql).each do |rec|
|
|
hash[rec.valid_from.try(:to_time)] = [{id: rec.state_dot_id, klass: self, param: :valid_from}] if rec.valid_from
|
|
hash[rec.valid_to.try(:to_time)] = [{id: rec.state_dot_id, klass: self, param: :valid_to}] if rec.valid_to
|
|
end
|
|
hash
|
|
end
|
|
|
|
def get_record_at domain_id, rec_id
|
|
sql = %Q{SELECT distinct 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} AND state.id = #{rec_id};}
|
|
find_by_sql(sql).first
|
|
end
|
|
end
|
|
end
|
|
end
|