diff --git a/app/services/import_repository/parse_repository.rb b/app/services/import_repository/parse_repository.rb index 23c6e1fc1..1bc5a1f5e 100644 --- a/app/services/import_repository/parse_repository.rb +++ b/app/services/import_repository/parse_repository.rb @@ -1,15 +1,18 @@ +# frozen_string_literal: true + module ImportRepository class ParseRepository include ActionView::Helpers::TextHelper def initialize(options) @file = options.fetch(:file) + @date_format = options[:date_format] @repository = options.fetch(:repository) @session = options.fetch(:session) @sheet = SpreadsheetParser.open_spreadsheet(@file) end def data - header, columns = SpreadsheetParser.first_two_rows(@sheet) + header, columns = SpreadsheetParser.first_two_rows(@sheet, date_format: @date_format) # Fill in fields for dropdown @repository.importable_repository_fields.transform_values! do |name| truncate(name, length: Constants::NAME_TRUNCATION_LENGTH_DROPDOWN) diff --git a/app/services/spreadsheet_parser.rb b/app/services/spreadsheet_parser.rb index 3be76b773..fbdbe6ebd 100644 --- a/app/services/spreadsheet_parser.rb +++ b/app/services/spreadsheet_parser.rb @@ -35,12 +35,12 @@ class SpreadsheetParser end end - def self.first_two_rows(sheet) + def self.first_two_rows(sheet, date_format: nil) rows = spreadsheet_enumerator(sheet) header = [] columns = [] rows.take(2).each_with_index do |row_values, i| - row = parse_row(row_values, sheet, header: i.zero?) + row = parse_row(row_values, sheet, header: i.zero?, date_format: date_format) if row && i.zero? header = row else