diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-04 18:09:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-04 18:09:12 +0300 |
commit | 856e2c64ee69b055b31a8ebbeee616f13a46505e (patch) | |
tree | 0ec9b70c8f1f74516631bf87281c175e127fedd2 /app/models/packages | |
parent | 8ed0a009f0ae0de789fae01b3cc9bda54aa03965 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/packages')
-rw-r--r-- | app/models/packages/cleanup.rb | 8 | ||||
-rw-r--r-- | app/models/packages/cleanup/policy.rb | 32 |
2 files changed, 40 insertions, 0 deletions
diff --git a/app/models/packages/cleanup.rb b/app/models/packages/cleanup.rb new file mode 100644 index 00000000000..16bba4f445d --- /dev/null +++ b/app/models/packages/cleanup.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +module Packages + module Cleanup + def self.table_name_prefix + 'packages_cleanup_' + end + end +end diff --git a/app/models/packages/cleanup/policy.rb b/app/models/packages/cleanup/policy.rb new file mode 100644 index 00000000000..87c101cfb8c --- /dev/null +++ b/app/models/packages/cleanup/policy.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Packages + module Cleanup + class Policy < ApplicationRecord + include Schedulable + + KEEP_N_DUPLICATED_PACKAGE_FILES_VALUES = %w[all 1 10 20 30 40 50].freeze + + self.primary_key = :project_id + + belongs_to :project + + validates :project, presence: true + validates :keep_n_duplicated_package_files, + inclusion: { + in: KEEP_N_DUPLICATED_PACKAGE_FILES_VALUES, + message: 'keep_n_duplicated_package_files is invalid' + } + + # used by Schedulable + def self.active + where.not(keep_n_duplicated_package_files: 'all') + end + + def set_next_run_at + # fixed cadence of 12 hours + self.next_run_at = Time.zone.now + 12.hours + end + end + end +end |