From 72ca8c57de7ed08b19a21efd9220ffcb3f1609e3 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 2 Apr 2023 17:11:53 +0200 Subject: [PATCH] Reduce SQL queries for querying tips. Closes CODEOCEAN-KY --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 187ccf42..fb0c095e 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -366,7 +366,7 @@ class ExercisesController < ApplicationController def set_available_tips # Order of elements is important and will be kept - available_tips = ExerciseTip.where(exercise: @exercise).order(rank: :asc) + available_tips = ExerciseTip.where(exercise: @exercise).order(rank: :asc).includes(:tip) # Transform result set in a hash and prepare (temporary) children array. # The children array will contain the sorted list of nested tips,