Reduce SQL queries for querying tips.

Closes CODEOCEAN-KY
This commit is contained in:
Sebastian Serth
2023-04-02 17:11:53 +02:00
parent 0aa73d30e9
commit 72ca8c57de

View File

@ -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,