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:
Diffstat (limited to 'db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb')
-rw-r--r--db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
new file mode 100644
index 00000000000..3e1c77ae992
--- /dev/null
+++ b/db/post_migrate/20190918104222_schedule_productivity_analytics_backfill.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class ScheduleProductivityAnalyticsBackfill < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ BATCH_SIZE = 10_000
+ INTERVAL = 3.minutes
+ MIGRATION = 'Gitlab::BackgroundMigration::RecalculateProductivityAnalytics'.freeze
+
+ disable_ddl_transaction!
+
+ def up
+ return unless Gitlab.ee?
+
+ metrics_model = Class.new(ActiveRecord::Base) do
+ self.table_name = 'merge_request_metrics'
+
+ include ::EachBatch
+ end
+
+ scope = metrics_model.where("merged_at >= ?", 3.months.ago)
+
+ queue_background_migration_jobs_by_range_at_intervals(scope, MIGRATION, INTERVAL, batch_size: BATCH_SIZE)
+ end
+
+ def down
+ # no-op
+ end
+end