From bf47729db10cc969b1690794a7a481b17492d0a1 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 21 Jun 2024 12:14:04 +0200 Subject: [PATCH] Fix cells preview mapping [SCI-10801] --- app/utilities/repository_import_parser/importer.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/utilities/repository_import_parser/importer.rb b/app/utilities/repository_import_parser/importer.rb index 491655660..de46587c0 100644 --- a/app/utilities/repository_import_parser/importer.rb +++ b/app/utilities/repository_import_parser/importer.rb @@ -129,8 +129,6 @@ module RepositoryImportParser include: [:repository_cells] ).as_json - p changes - { status: :ok, nr_of_added: @new_rows_added, total_nr: @total_new_rows, changes: changes, import_date: I18n.l(Date.today, format: :full_date) } end @@ -152,7 +150,7 @@ module RepositoryImportParser if @preview repository_row.validate - repository_row.id = SecureRandom.uuid unless repository_row.id.present? # ID required for preview with serializer + repository_row.id = SecureRandom.uuid.gsub(/[a-zA-Z-]/, '') unless repository_row.id.present? # ID required for preview with serializer else repository_row.save! end @@ -245,7 +243,12 @@ module RepositoryImportParser # Create new cell cell_value.repository_cell.value = cell_value repository_row.repository_cells << cell_value.repository_cell - @preview ? cell_value.validate : cell_value.save! + if @preview + cell_value.validate + cell_value.repository_cell.id = SecureRandom.uuid.gsub(/[a-zA-Z-]/, '') unless cell_value.repository_cell.id.present? # ID required for preview with serializer + else + cell_value.save! + end @updated ||= true cell_value.repository_cell end