diff options
Diffstat (limited to 'app/models/container_expiration_policy.rb')
-rw-r--r-- | app/models/container_expiration_policy.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/container_expiration_policy.rb b/app/models/container_expiration_policy.rb index 641d244b665..3f91f6c796a 100644 --- a/app/models/container_expiration_policy.rb +++ b/app/models/container_expiration_policy.rb @@ -5,6 +5,13 @@ class ContainerExpirationPolicy < ApplicationRecord include UsageStatistics include EachBatch + POLICY_PARAMS = %w[ + older_than + keep_n + name_regex + name_regex_keep + ].freeze + belongs_to :project, inverse_of: :container_expiration_policy delegate :container_repositories, to: :project @@ -20,8 +27,8 @@ class ContainerExpirationPolicy < ApplicationRecord scope :active, -> { where(enabled: true) } scope :preloaded, -> { preload(project: [:route]) } - def self.executable - runnable_schedules.where( + def self.with_container_repositories + where( 'EXISTS (?)', ContainerRepository.select(1) .where( @@ -67,4 +74,8 @@ class ContainerExpirationPolicy < ApplicationRecord def disable! update_attribute(:enabled, false) end + + def policy_params + attributes.slice(*POLICY_PARAMS) + end end |