debian-mirror-gitlab/app/workers/group_import_worker.rb

26 lines
638 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
2020-04-08 14:13:33 +05:30
class GroupImportWorker # rubocop:disable Scalability/IdempotentWorker
2020-03-13 15:44:24 +05:30
include ApplicationWorker
2021-01-03 14:25:43 +05:30
sidekiq_options retry: false, dead: false
2020-03-13 15:44:24 +05:30
feature_category :importers
def perform(user_id, group_id)
current_user = User.find(user_id)
group = Group.find(group_id)
2021-01-03 14:25:43 +05:30
group_import_state = group.import_state
2020-05-24 23:13:21 +05:30
2020-06-23 00:09:42 +05:30
group_import_state.jid = self.jid
group_import_state.start!
2020-03-13 15:44:24 +05:30
::Groups::ImportExport::ImportService.new(group: group, user: current_user).execute
2020-05-24 23:13:21 +05:30
2020-06-23 00:09:42 +05:30
group_import_state.finish!
2020-05-24 23:13:21 +05:30
rescue StandardError => e
2020-06-23 00:09:42 +05:30
group_import_state&.fail_op(e.message)
2020-05-24 23:13:21 +05:30
raise e
2020-03-13 15:44:24 +05:30
end
end