Class: Gitlab::BackgroundMigration::MoveCiBuildsMetadata::JobsFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/move_ci_builds_metadata.rb

Overview

The migration iterates over an entire p_ci_builds partition and with this class we’re applying the user defined cutoff policies so that only the relevant data is copied.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(migration, jobs_batch, config) ⇒ JobsFilter

Returns a new instance of JobsFilter.



125
126
127
128
129
130
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 125

def initialize(migration, jobs_batch, config)
  @migration = migration
  @jobs_batch = jobs_batch
  @config = config
  @jobs_cache = {}
end

Instance Attribute Details

#jobs_batchObject (readonly)

Returns the value of attribute jobs_batch.



123
124
125
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 123

def jobs_batch
  @jobs_batch
end

#migrationObject (readonly)

Returns the value of attribute migration.



123
124
125
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 123

def migration
  @migration
end

Instance Method Details

#job_ids_filterObject



132
133
134
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 132

def job_ids_filter
  @job_ids_filter ||= load_jobs_created_after(migration_cutoff).pluck(:id, :partition_id)
end

#jobs_for_definitionsObject



136
137
138
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 136

def jobs_for_definitions
  @jobs_for_definitions ||= load_jobs_created_after(processing_data_cutoff)
end

#jobs_for_environmentsObject



140
141
142
143
144
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 140

def jobs_for_environments
  return jobs_batch unless migration_cutoff.present?

  jobs_batch.where(created_at: migration_cutoff...)
end