Class: Projects::ImportExport::CreateRelationExportsWorker
- Inherits:
-
Object
- Object
- Projects::ImportExport::CreateRelationExportsWorker
- Includes:
- ApplicationWorker, ExceptionBacktrace
- Defined in:
- app/workers/projects/import_export/create_relation_exports_worker.rb
Constant Summary collapse
- INITIAL_DELAY =
This delay is an arbitrary number to finish the export quicker in case all relations are exported before the first execution of the WaitRelationExportsWorker worker.
10.seconds
Constants included from ApplicationWorker
ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT
Constants included from Gitlab::Loggable
Constants included from WorkerAttributes
WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES
Instance Method Summary collapse
-
#perform(user_id, project_id, after_export_strategy = {}, params = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
Methods included from Gitlab::Loggable
Methods included from Gitlab::SidekiqVersioning::Worker
Methods included from WorkerContext
Instance Method Details
#perform(user_id, project_id, after_export_strategy = {}, params = {}) ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/workers/projects/import_export/create_relation_exports_worker.rb', line 21 def perform(user_id, project_id, after_export_strategy = {}, params = {}) project = Project.find_by_id(project_id) return unless project params.symbolize_keys! project_export_job = project.export_jobs.find_or_create_by!(jid: jid) do |export_job| export_job.user_id = user_id export_job.exported_by_admin = !!params[:exported_by_admin] end return if project_export_job.started? relation_exports = RelationExport.relation_names_list.map do |relation_name| project_export_job.relation_exports.find_or_create_by!(relation: relation_name) end relation_exports.each do |relation_export| RelationExportWorker.with_status.perform_async(relation_export.id, user_id, params) end project_export_job.start! WaitRelationExportsWorker.perform_in( INITIAL_DELAY, project_export_job.id, user_id, after_export_strategy ) end |