simplify children_of

This commit is contained in:
simon lehericey 2022-05-18 12:30:58 +02:00
parent 61c22e6324
commit 1921661fad

View file

@ -155,15 +155,11 @@ class ProcedureRevision < ApplicationRecord
end
def children_of(tdc)
parent_revision_type_de_champ = revision_types_de_champ.find_by(type_de_champ: tdc)
parent_coordinate_id = revision_types_de_champ.where(type_de_champ: tdc).select(:id)
if parent_revision_type_de_champ.present?
types_de_champ
.where(procedure_revision_types_de_champ: { parent_id: parent_revision_type_de_champ.id })
.order("procedure_revision_types_de_champ.position")
else
TypeDeChamp.none
end
types_de_champ
.where(procedure_revision_types_de_champ: { parent_id: parent_coordinate_id })
.order("procedure_revision_types_de_champ.position")
end
private