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

batched_background_migrations.rb « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ce7115e5cd5828eadcfeb959dd0ffb7395156552 (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
28
29
30
31
32
# frozen_string_literal: true

module RuboCop
  class BatchedBackgroundMigrations
    DICTIONARY_BASE_DIR = 'db/docs/batched_background_migrations'

    attr_reader :queued_migration_version

    class << self
      def dictionary_data
        @dictionary_data ||= Dir.glob("*.yml", base: DICTIONARY_BASE_DIR).each_with_object({}) do |file_name, data|
          dictionary = YAML.load_file(File.join(DICTIONARY_BASE_DIR, file_name))

          next unless dictionary['queued_migration_version'].present?

          data[dictionary['queued_migration_version'].to_s] = {
            finalize_after: dictionary['finalize_after'],
            finalized_by: dictionary['finalized_by'].to_s
          }
        end
      end
    end

    def initialize(queued_migration_version)
      @queued_migration_version = queued_migration_version
    end

    def finalized_by
      self.class.dictionary_data.dig(queued_migration_version.to_s, :finalized_by)
    end
  end
end