Use query filter instead of array.reject

This commit is contained in:
Mathieu Magnin 2019-02-26 11:39:32 +01:00
parent f5933ef2e5
commit fed1f3e921

View file

@ -49,11 +49,11 @@ class ProcedurePresentation < ApplicationRecord
explanatory_types_de_champ = [:header_section, :explication].map { |k| TypeDeChamp.type_champs.fetch(k) }
fields.concat procedure.types_de_champ
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
.where.not(type_champ: explanatory_types_de_champ)
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s) }
fields.concat procedure.types_de_champ_private
.reject { |tdc| explanatory_types_de_champ.include?(tdc.type_champ) }
.where.not(type_champ: explanatory_types_de_champ)
.map { |type_de_champ| field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s) }
fields