From 96cd4fda72fafe0130a3ea5ebafb066a33a2c7c2 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 16:38:43 +0100 Subject: [PATCH] ensure exported columns existed in main columns function --- app/models/concerns/columns_concern.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 7590cf80e..d360d3d1d 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -36,18 +36,19 @@ module ColumnsConcern columns.concat(moral_columns) if !for_individual columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete? - columns.flatten.compact + # ensure the columns exist in main list + columns.filter { _1.id.in?(self.columns.map(&:id)) } end def dossier_columns_for_export - columns = [dossier_state_column] - columns.concat([dossier_archived_column]) + columns = [dossier_state_column, dossier_archived_column] columns.concat(dossier_dates_columns) columns.concat([dossier_motivation_column]) columns.concat(sva_svr_columns(for_export: true)) if sva_svr_enabled? - columns.concat([groupe_instructeurs_id_column]) - columns.concat([followers_instructeurs_email_column]) - columns.flatten.compact + columns.concat([groupe_instructeurs_id_column, followers_instructeurs_email_column]) + + # ensure the columns exist in main list + columns.filter { _1.id.in?(self.columns.map(&:id)) } end def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number)