Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gaprindashvili]move #my_zone from ArchivedMixin to OldEmsMixin #17540

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class Container < ApplicationRecord
include SupportsFeatureMixin
include NewWithTypeStiMixin
include ArchivedMixin
include OldEmsMixin
include_concern 'Purging'

belongs_to :container_group
Expand Down
1 change: 1 addition & 0 deletions app/models/container_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ContainerGroup < ApplicationRecord
include NewWithTypeStiMixin
include TenantIdentityMixin
include ArchivedMixin
include OldEmsMixin
include CustomActionsMixin
include CockpitSupportMixin
include_concern 'Purging'
Expand Down
1 change: 1 addition & 0 deletions app/models/container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ContainerImage < ApplicationRecord
include TenantIdentityMixin
include CustomAttributeMixin
include ArchivedMixin
include OldEmsMixin
include NewWithTypeStiMixin
include CustomActionsMixin
include_concern 'Purging'
Expand Down
1 change: 1 addition & 0 deletions app/models/container_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ContainerNode < ApplicationRecord
include TenantIdentityMixin
include SupportsFeatureMixin
include ArchivedMixin
include OldEmsMixin
include CockpitMixin
include CustomActionsMixin
include_concern 'Purging'
Expand Down
1 change: 1 addition & 0 deletions app/models/container_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ContainerProject < ApplicationRecord
include SupportsFeatureMixin
include CustomAttributeMixin
include ArchivedMixin
include OldEmsMixin
include CustomActionsMixin
include_concern 'Purging'
belongs_to :ext_management_system, :foreign_key => "ems_id"
Expand Down
13 changes: 0 additions & 13 deletions app/models/mixins/archived_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module ArchivedMixin
included do
scope :archived, -> { where.not(:deleted_on => nil) }
scope :active, -> { where(:deleted_on => nil) }

belongs_to :old_ext_management_system, :foreign_key => :old_ems_id, :class_name => 'ExtManagementSystem'
end

def archived?
Expand All @@ -15,15 +13,4 @@ def archived?
def active?
deleted_on.nil?
end

# Needed for metrics
def my_zone
if ext_management_system.present?
ext_management_system.my_zone
elsif old_ext_management_system.present?
# Archived container entities need to retain their zone for metric collection
# This makes the association more complex and might need a performance fix
old_ext_management_system.my_zone
end
end
end
18 changes: 18 additions & 0 deletions app/models/mixins/old_ems_mixin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module OldEmsMixin
extend ActiveSupport::Concern

included do
belongs_to :old_ext_management_system, :foreign_key => :old_ems_id, :class_name => 'ExtManagementSystem'
end

# Needed for metrics
def my_zone
if ext_management_system.present?
ext_management_system.my_zone
elsif old_ext_management_system.present?
# Archived container entities need to retain their zone for metric collection
# This makes the association more complex and might need a performance fix
old_ext_management_system.my_zone
end
end
end