From 3af1cee240b1903b3e9af6207e430ffbdba909ab Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 14 May 2024 17:11:12 +0200 Subject: [PATCH] refactor: simplify --- app/models/concerns/tags_substitution_concern.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index a7088fbd5..8ddef3b03 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -287,14 +287,13 @@ module TagsSubstitutionConcern valid_tags = tags_for_dossier_state(tags) valid_tags.each do |tag| - result[tag[:id]] = [tag, dossier] + result[tag[:id]] = tag end end tags_and_libelles.each_with_object({}) do |(tag_id, libelle), substitutions| - substitutions[tag_id] = case flat_tags[tag_id] - in tag, dossier - replace_tag(tag, dossier) + substitutions[tag_id] = if flat_tags[tag_id].present? + replace_tag(flat_tags[tag_id], dossier) else # champ not in dossier, for example during preview on draft revision libelle end