Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 18:09:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 18:09:09 +0300
commitd0bb0e04f40b962576353ce56e270aa7bd25a5c0 (patch)
tree8d78f5e9adf8d965f84869c936ac997e8748900e /lib
parent0eea37aefa31ed22e32eadbe6164dd92e3c64ec2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/purge_stale_security_scans.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/purge_stale_security_scans.rb b/lib/gitlab/background_migration/purge_stale_security_scans.rb
new file mode 100644
index 00000000000..8b13a0382b4
--- /dev/null
+++ b/lib/gitlab/background_migration/purge_stale_security_scans.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # rubocop:disable Style/Documentation
+ class PurgeStaleSecurityScans # rubocop:disable Migration/BackgroundMigrationBaseClass
+ class SecurityScan < ::ApplicationRecord
+ include EachBatch
+
+ STALE_AFTER = 90.days
+
+ self.table_name = 'security_scans'
+
+ # Otherwise the schema_spec fails
+ validates :info, json_schema: { filename: 'security_scan_info', draft: 7 }
+
+ enum status: { succeeded: 1, purged: 6 }
+
+ scope :to_purge, -> { where('id <= ?', last_stale_record_id) }
+ scope :by_range, -> (range) { where(id: range) }
+
+ def self.last_stale_record_id
+ where('created_at < ?', STALE_AFTER.ago).order(created_at: :desc).first
+ end
+ end
+
+ def perform(_start_id, _end_id); end
+ end
+ end
+end
+
+Gitlab::BackgroundMigration::PurgeStaleSecurityScans.prepend_mod