Merge pull request #7346 from betagouv/simplier_children_of

simplify children_of
This commit is contained in:
LeSim 2022-05-18 14:30:18 +02:00 committed by GitHub
commit 86eec7b315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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