summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/populate_latest_pipeline_ids.rb
blob: a2b25a293fef7c0b34f412b8ea08f3202e5693dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

# rubocop: disable Style/Documentation
module Gitlab
  module BackgroundMigration
    class PopulateLatestPipelineIds
      class ProjectSetting < ActiveRecord::Base
        include EachBatch

        self.table_name = 'project_settings'

        scope :in_range, -> (start_id, end_id) { where(id: start_id..end_id) }
        scope :has_vulnerabilities_without_latest_pipeline_set, -> do
          joins('LEFT OUTER JOIN vulnerability_statistics vs ON vs.project_id = project_settings.project_id')
            .where(vs: { latest_pipeline_id: nil })
            .where('has_vulnerabilities IS TRUE')
        end
      end

      def perform(start_id, end_id)
        # no-op
      end
    end
  end
end

Gitlab::BackgroundMigration::PopulateLatestPipelineIds.prepend_mod