Avoid useless TypeDeChamp deserialization

- 520 objects overs 4720 (10%) created in app/ (using ?pp=profile-memory&memory_profiler_allow_files=app/)
This commit is contained in:
simon lehericey 2021-04-16 12:31:29 +02:00
parent e728a3fcb7
commit 47f13219ed

View file

@ -65,12 +65,14 @@ class ProcedurePresentation < ApplicationRecord
fields.concat procedure.types_de_champ
.where.not(type_champ: explanatory_types_de_champ)
.order(:id)
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.stable_id.to_s) }
.pluck(:libelle, :stable_id)
.map { |(libelle, stable_id)| field_hash(libelle, 'type_de_champ', stable_id.to_s) }
fields.concat procedure.types_de_champ_private
.where.not(type_champ: explanatory_types_de_champ)
.order(:id)
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.stable_id.to_s) }
.pluck(:libelle, :stable_id)
.map { |(libelle, stable_id)| field_hash(libelle, 'type_de_champ_private', stable_id.to_s) }
fields
end