From fe2e8ae7932e64cd981acacae5ba916107684ec3 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 20 Aug 2024 17:12:01 +0200 Subject: [PATCH] fix(instructeur): never try to strftime on non date value --- app/services/dossier_projection_service.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/services/dossier_projection_service.rb b/app/services/dossier_projection_service.rb index 92089b1e6..0663f3c83 100644 --- a/app/services/dossier_projection_service.rb +++ b/app/services/dossier_projection_service.rb @@ -75,10 +75,11 @@ class DossierProjectionService .pluck(:id, *fields.map { |f| f[COLUMN].to_sym }) .each do |id, *columns| fields.zip(columns).each do |field, value| - if [state_field, archived_field, hidden_by_user_at_field, hidden_by_administration_at_field, hidden_by_reason_field, for_tiers_field, batch_operation_field, sva_svr_decision_on_field].include?(field) - field[:id_value_h][id] = value + # SVA must remain a date: in other column we compute remaining delay with it + field[:id_value_h][id] = if value.respond_to?(:strftime) && field != sva_svr_decision_on_field + I18n.l(value.to_date) else - field[:id_value_h][id] = value&.strftime('%d/%m/%Y') # other fields are datetime + value end end end