From 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Feb 2023 13:49:51 +0000 Subject: Add latest changes from gitlab-org/gitlab@15-9-stable-ee --- app/services/work_items/export_csv_service.rb | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/services/work_items/export_csv_service.rb (limited to 'app/services/work_items/export_csv_service.rb') diff --git a/app/services/work_items/export_csv_service.rb b/app/services/work_items/export_csv_service.rb new file mode 100644 index 00000000000..9bef75e2c40 --- /dev/null +++ b/app/services/work_items/export_csv_service.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module WorkItems + class ExportCsvService < ExportCsv::BaseService + NotAvailableError = StandardError.new('This feature is currently behind a feature flag and it is not available.') + + def csv_data + raise NotAvailableError unless Feature.enabled?(:import_export_work_items_csv, resource_parent) + + super + end + + def email(mail_to_user) + # TODO - will be implemented as part of https://gitlab.com/gitlab-org/gitlab/-/issues/379082 + end + + private + + def associations_to_preload + [:work_item_type, :author] + end + + def header_to_value_hash + { + 'Id' => 'iid', + 'Title' => 'title', + 'Type' => ->(work_item) { work_item.work_item_type.name }, + 'Author' => 'author_name', + 'Author Username' => ->(work_item) { work_item.author.username }, + 'Created At (UTC)' => ->(work_item) { work_item.created_at.to_s(:csv) } + } + end + end +end -- cgit v1.2.3