Class: GroupImportWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/group_import_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(user_id, group_id) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/workers/group_import_worker.rb', line 9

def perform(user_id, group_id)
  current_user = User.find(user_id)
  group = Group.find(group_id)
  group_import_state = group.import_state || group.build_import_state

  group_import_state.jid = self.jid
  group_import_state.start!

  ::Groups::ImportExport::ImportService.new(group: group, user: current_user).execute

  group_import_state.finish!
rescue StandardError => e
  group_import_state&.fail_op(e.message)

  raise e
end