2018-12-06 00:51:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class ImportIssuesCsvWorker # rubocop:disable Scalability/IdempotentWorker
|
2018-12-06 00:51:30 +00:00
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-11-24 21:09:39 +00:00
|
|
|
idempotent!
|
2021-10-27 15:13:41 +00:00
|
|
|
feature_category :team_planning
|
2019-10-30 15:14:17 +00:00
|
|
|
worker_resource_boundary :cpu
|
2020-01-24 18:09:00 +00:00
|
|
|
weight 2
|
2019-10-18 11:11:44 +00:00
|
|
|
|
2019-01-03 05:17:07 +00:00
|
|
|
sidekiq_retries_exhausted do |job|
|
|
|
|
Upload.find(job['args'][2]).destroy
|
|
|
|
end
|
|
|
|
|
2018-12-06 00:51:30 +00:00
|
|
|
def perform(current_user_id, project_id, upload_id)
|
2020-11-24 21:09:39 +00:00
|
|
|
user = User.find(current_user_id)
|
|
|
|
project = Project.find(project_id)
|
|
|
|
upload = Upload.find(upload_id)
|
2018-12-06 00:51:30 +00:00
|
|
|
|
2020-11-24 21:09:39 +00:00
|
|
|
importer = Issues::ImportCsvService.new(user, project, upload.retrieve_uploader)
|
2018-12-06 00:51:30 +00:00
|
|
|
importer.execute
|
|
|
|
|
2020-11-24 21:09:39 +00:00
|
|
|
upload.destroy
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
# Resources have been removed, job should not be retried
|
2018-12-06 00:51:30 +00:00
|
|
|
end
|
|
|
|
end
|