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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 14:59:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 14:59:07 +0300
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb
parent4b1de649d0168371549608993deac953eb692019 (diff)
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb')
-rw-r--r--db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb b/db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb
new file mode 100644
index 00000000000..598cc4d93d0
--- /dev/null
+++ b/db/post_migrate/20201119092319_schedule_repopulate_historical_vulnerability_statistics.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class ScheduleRepopulateHistoricalVulnerabilityStatistics < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 50
+ DELAY_INTERVAL = 5.minutes
+ MIGRATION_CLASS = 'PopulateVulnerabilityHistoricalStatistics'
+ DAY_COUNT = 365
+
+ disable_ddl_transaction!
+
+ class ProjectSetting < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'project_settings'
+
+ scope :has_vulnerabilities, -> { where('has_vulnerabilities IS TRUE') }
+ end
+
+ def up
+ ProjectSetting.has_vulnerabilities.each_batch(of: BATCH_SIZE) do |batch, index|
+ migrate_in(index * DELAY_INTERVAL, MIGRATION_CLASS, [batch.pluck(:project_id), DAY_COUNT])
+ end
+ end
+
+ def down
+ # no-op
+ end
+end