Class: Gitlab::BackgroundMigration::MoveCiBuildsMetadata::JobsPreloader

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

Overview

Not all data resides in the builds_metadata table, so we need to query other tables too. Since we can’t use application code here, we’re building a similar abstraction to the ActiveRecord preloader to load connected data. It returns a new jobs collection with tags, execution steps, and the metadata record.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(migration, jobs) ⇒ JobsPreloader

Returns a new instance of JobsPreloader.



190
191
192
193
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 190

def initialize(migration, jobs)
  @migration = migration
  @jobs = jobs
end

Instance Attribute Details

#jobsObject (readonly)

Returns the value of attribute jobs.



188
189
190
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 188

def jobs
  @jobs
end

Instance Method Details

#executeObject



195
196
197
198
199
200
201
202
203
204
# File 'lib/gitlab/background_migration/move_ci_builds_metadata.rb', line 195

def execute
  jobs.map do |job|
    JobPresenter.new(
      job,
      metadata: [job.id],
      tag_list: tag_records[job.id],
      run_steps: run_steps_records[job.id]
    )
  end
end