From 450420aa814d8a2619f62c3d32cdf15f2bcc9c4d Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 25 Sep 2024 12:43:23 +0200 Subject: [PATCH] cache columns per request using Current --- app/models/concerns/columns_concern.rb | 14 +++++++++----- app/models/current.rb | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index caac5bc74..102df0b7a 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -10,11 +10,15 @@ module ColumnsConcern end def columns - columns = dossier_columns - columns.concat(standard_columns) - columns.concat(individual_columns) if for_individual - columns.concat(moral_columns) if !for_individual - columns.concat(types_de_champ_columns) + Current.procedure_columns ||= {} + + Current.procedure_columns[id] ||= begin + columns = dossier_columns + columns.concat(standard_columns) + columns.concat(individual_columns) if for_individual + columns.concat(moral_columns) if !for_individual + columns.concat(types_de_champ_columns) + end end def dossier_id_column diff --git a/app/models/current.rb b/app/models/current.rb index a2f863f3e..77045cfff 100644 --- a/app/models/current.rb +++ b/app/models/current.rb @@ -9,4 +9,5 @@ class Current < ActiveSupport::CurrentAttributes attribute :no_reply_email attribute :request_id attribute :user + attribute :procedure_columns end