diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-04 18:09:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-04 18:09:15 +0300 |
commit | da602b32e45431234e592e8f7001c3ace1771765 (patch) | |
tree | e290cbaa27372e5a00d4581de79244755edde393 /app/workers | |
parent | f1500a385abba1f03c0eadc3c6a95ea532030b4c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/issuable_export_csv_worker.rb | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/app/workers/issuable_export_csv_worker.rb b/app/workers/issuable_export_csv_worker.rb index 33452b14edb..eb96a78497c 100644 --- a/app/workers/issuable_export_csv_worker.rb +++ b/app/workers/issuable_export_csv_worker.rb @@ -10,29 +10,21 @@ class IssuableExportCsvWorker # rubocop:disable Scalability/IdempotentWorker def perform(type, current_user_id, project_id, params) user = User.find(current_user_id) project = Project.find(project_id) - finder_params = map_params(params, project_id) - export_service(type.to_sym, user, project, finder_params).email(user) + export_service(type, user, project, params).email(user) rescue ActiveRecord::RecordNotFound => error logger.error("Failed to export CSV (current_user_id:#{current_user_id}, project_id:#{project_id}): #{error.message}") end private - def map_params(params, project_id) - params - .symbolize_keys - .except(:sort) - .merge(project_id: project_id) - end - def export_service(type, user, project, params) - issuable_class = service_classes_for(type) - issuables = issuable_class[:finder].new(user, params).execute - issuable_class[:service].new(issuables, project) + issuable_classes = issuable_classes_for(type.to_sym) + issuables = issuable_classes[:finder].new(user, parse_params(params, project.id)).execute + issuable_classes[:service].new(issuables, project) end - def service_classes_for(type) + def issuable_classes_for(type) case type when :issue { finder: IssuesFinder, service: Issues::ExportCsvService } @@ -43,6 +35,13 @@ class IssuableExportCsvWorker # rubocop:disable Scalability/IdempotentWorker end end + def parse_params(params, project_id) + params + .symbolize_keys + .except(:sort) + .merge(project_id: project_id) + end + def type_error_message(type) "Type parameter must be :issue or :merge_request, it was #{type}" end |