class Competitions::TeachersController < Competitions::BaseController def index keyword = params[:keyword].to_s.strip if keyword.blank? @teachers = [] return end teachers = User.joins(:user_extension).where(status: 1, user_extensions: { identity: 0 }) teachers = teachers.where.not(id: params[:teacher_ids]) if params[:teacher_ids].present? teachers = teachers.where('LOWER(CONCAT(lastname, firstname, login, nickname)) LIKE ?', "%#{keyword}%") @teachers = teachers.includes(user_extension: :school).limit(10) # 老师多次报名限制 if current_competition.teacher_multiple_limited? ids = @teachers.map(&:id) members = current_competition.team_members.where(user_id: ids) members = members.where.not(competition_team_id: params[:team_id]) if params[:team_id].present? @enrolled_map = members.group(:user_id).count end end end