diff options
Diffstat (limited to 'app/services/issuable/import_csv')
-rw-r--r-- | app/services/issuable/import_csv/base_service.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/services/issuable/import_csv/base_service.rb b/app/services/issuable/import_csv/base_service.rb index 9ef9fb76e3c..95338374ca6 100644 --- a/app/services/issuable/import_csv/base_service.rb +++ b/app/services/issuable/import_csv/base_service.rb @@ -23,6 +23,24 @@ module Issuable raise CSV::MalformedCSVError.new('Invalid CSV format - missing required headers.', 1) end + + def preprocess! + preprocess_milestones! + + raise PreprocessError if results[:preprocess_errors].any? + end + + def preprocess_milestones! + # Pre-Process Milestone if header is present + return unless csv_data.lines.first.downcase.include?('milestone') + + provided_titles = with_csv_lines.filter_map { |row| row[:milestone]&.strip&.downcase }.uniq + result = ::ImportCsv::PreprocessMilestonesService.new(user, project, provided_titles).execute + return if result.success? + + # collate errors here and throw errors + results[:preprocess_errors][:milestone_errors] = result.payload + end end end end |