class Admins::MyshixunsController < Admins::BaseController def index params[:sort_by] = params[:sort_by].presence || 'created_at' params[:sort_direction] = params[:sort_direction].presence || 'desc' myshixuns = Admins::MyshixunQuery.call(params) @myshixuns = paginate myshixuns.includes(:last_executable_task, :last_task, shixun: :user, user: { user_extension: :school }) myshixun_ids = @myshixuns.map(&:id) @finish_game_count = Game.where(myshixun_id: myshixun_ids, status: 2).group(:myshixun_id).count @total_score = Game.where(myshixun_id: myshixun_ids, status: 2).where('final_score > 0').group(:myshixun_id).sum(:final_score) end end