From b9bbe70ec5804f448b6f3cd473c8fbaa5742852a Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 26 Jan 2024 14:54:03 +0100 Subject: [PATCH] perf(Administrateurs::ConditionsController#*): better perfs --- app/controllers/administrateurs/conditions_controller.rb | 1 + app/models/procedure_revision_type_de_champ.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/administrateurs/conditions_controller.rb b/app/controllers/administrateurs/conditions_controller.rb index 30a443f21..74107500b 100644 --- a/app/controllers/administrateurs/conditions_controller.rb +++ b/app/controllers/administrateurs/conditions_controller.rb @@ -54,6 +54,7 @@ module Administrateurs end def retrieve_coordinate_and_uppers + ProcedureRevisionPreloader.load_one(draft_revision) @tdc = draft_revision.find_and_ensure_exclusive_use(params[:stable_id]) @coordinate = draft_revision.coordinate_for(@tdc) @upper_tdcs = @coordinate.upper_coordinates.map(&:type_de_champ) diff --git a/app/models/procedure_revision_type_de_champ.rb b/app/models/procedure_revision_type_de_champ.rb index 2c27f26bf..c4842da20 100644 --- a/app/models/procedure_revision_type_de_champ.rb +++ b/app/models/procedure_revision_type_de_champ.rb @@ -31,7 +31,7 @@ class ProcedureRevisionTypeDeChamp < ApplicationRecord def siblings if parent_id.present? - revision.revision_types_de_champ.filter { _1.parent_id == parent_id } + revision.revision_types_de_champ.where(parent_id: parent_id).ordered elsif private? revision.revision_types_de_champ_private else