Class: ProjectExportWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, ExceptionBacktrace
Defined in:
app/workers/project_export_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(current_user_id, project_id, after_export_strategy = {}, params = {}) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workers/project_export_worker.rb', line 14

def perform(current_user_id, project_id, after_export_strategy = {}, params = {})
  current_user = User.find(current_user_id)
  project = Project.find(project_id)
  export_job = project.export_jobs.safe_find_or_create_by(jid: self.jid)
  after_export = build!(after_export_strategy)

  export_job&.start

  ::Projects::ImportExport::ExportService.new(project, current_user, params).execute(after_export)

  export_job&.finish
rescue ActiveRecord::RecordNotFound, Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError => e
  logger.error("Failed to export project #{project_id}: #{e.message}")
end