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
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
sidekiq_options retry: 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)
|
2020-05-24 23:13:21 +05:30
|
|
|
group_import = group.build_import_state(jid: self.jid)
|
|
|
|
|
|
|
|
group_import.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
|
|
|
|
|
|
|
group_import.finish!
|
|
|
|
rescue StandardError => e
|
|
|
|
group_import&.fail_op(e.message)
|
|
|
|
|
|
|
|
raise e
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|