From 71e017bfd76f32631cdfd3087e5e758ff4057f05 Mon Sep 17 00:00:00 2001 From: yoopie Date: Thu, 12 Sep 2024 11:06:25 +0800 Subject: [PATCH] perf(live-feedback-stats): reduce N+1 - sql queries drop from 99 -> ~30 --- app/controllers/course/statistics/assessments_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/course/statistics/assessments_controller.rb b/app/controllers/course/statistics/assessments_controller.rb index d40b623563..80571eee7e 100644 --- a/app/controllers/course/statistics/assessments_controller.rb +++ b/app/controllers/course/statistics/assessments_controller.rb @@ -42,7 +42,8 @@ def live_feedback_statistics preload(course: :course_users).first submissions = Course::Assessment::Submission.where(assessment_id: assessment_params[:id]). preload(creator: :course_users) - assessment_live_feedbacks = Course::Assessment::LiveFeedback.where(assessment_id: assessment_params[:id]) + assessment_live_feedbacks = Course::Assessment::LiveFeedback.where(assessment_id: assessment_params[:id]). + preload(:creator, creator: :course_users, code: :comments) @course_users_hash = preload_course_users_hash(@assessment.course)