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

set_correct_vulnerability_state.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd6cbcb8d05a86f86c6c3d85f7fcbc69774120a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Change the vulnerability state to `dismissed` if `dismissed_at` field is not null
    class SetCorrectVulnerabilityState < BatchedMigrationJob
      DISMISSED_STATE = 2

      def perform
        each_sub_batch(
          operation_name: :update_vulnerabilities_state,
          batching_scope: -> (relation) { relation.where.not(dismissed_at: nil) }
        ) do |sub_batch|
          sub_batch.update_all(state: DISMISSED_STATE)
        end
      end
    end
  end
end