Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Eager load assessment stats page, 90% fewer queries!
Browse files Browse the repository at this point in the history
  • Loading branch information
allenwq committed Nov 6, 2015
1 parent 908b7bb commit 56a19ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/assessment/assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ def stats
@summary = {}
@summary[:type] = @assessment.is_mission? ? 'mission' : 'training'
@stats_paging = @course.paging_pref(@assessment.is_mission? ? "MissionStats" : "TrainingStats")
@submissions = @assessment.submissions.includes(:gradings)
std_courses = @course.user_courses.student.order(:name).where(is_phantom: false)
my_std = curr_user_course.std_courses.student.order(:name).where(is_phantom: false)
std_phantom = @course.user_courses.student.order(:name).where(is_phantom: true)
@submissions = @assessment.submissions.includes(gradings: :exp_transaction)
std_courses = @course.user_courses.student.order(:name).where(is_phantom: false).includes(:tut_courses)
my_std = curr_user_course.std_courses.student.order(:name).where(is_phantom: false).includes(:tut_courses)
std_phantom = @course.user_courses.student.order(:name).where(is_phantom: true).includes(:tut_courses)

if @stats_paging.display?
std_courses = std_courses.page(params[:page]).per(@stats_paging.prefer_value.to_i)
Expand Down

0 comments on commit 56a19ab

Please sign in to comment.