Merge pull request #7346 from betagouv/simplier_children_of
simplify children_of
This commit is contained in:
commit
86eec7b315
1 changed files with 4 additions and 8 deletions
|
@ -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 })
|
||||
.where(procedure_revision_types_de_champ: { parent_id: parent_coordinate_id })
|
||||
.order("procedure_revision_types_de_champ.position")
|
||||
else
|
||||
TypeDeChamp.none
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue