Reduce SQL queries in the exercise controller

Fixes CODEOCEAN-JK
This commit is contained in:
Sebastian Serth
2023-03-14 20:58:21 +01:00
parent d410c67473
commit a7cd85507e
4 changed files with 10 additions and 6 deletions

View File

@@ -29,9 +29,9 @@ h1 = Exercise.model_name.human(count: 2)
tr data-id=exercise.id
td.p-1.pt-2 = link_to_if(policy(exercise).show?, exercise.title, exercise, 'data-turbolinks' => "false")
td.p-1.pt-2 = link_to_if(exercise.execution_environment && policy(exercise.execution_environment).show?, exercise.execution_environment, exercise.execution_environment)
td.p-1.pt-2 = exercise.files.teacher_defined_assessments.count
td.p-1.pt-2 = exercise.files.filter(&:teacher_defined_assessment?).length
td.p-1.pt-2 = exercise.maximum_score
td.p-1.pt-2 = exercise.exercise_tags.count
td.p-1.pt-2 = exercise.exercise_tags.length
td.p-1.pt-2 = exercise.expected_difficulty
td.p-1.pt-2.public data-value=exercise.public? = symbol_for(exercise.public?)
td.p-1.pt-2 = link_to(t('shared.edit'), edit_exercise_path(exercise)) if policy(exercise).edit?