You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
910 B
23 lines
910 B
5 years ago
|
class Competitions::StudentsController < Competitions::BaseController
|
||
|
def index
|
||
|
keyword = params[:keyword].to_s.strip
|
||
|
if keyword.blank?
|
||
|
@students = []
|
||
|
return
|
||
|
end
|
||
|
|
||
|
students = User.joins(:user_extension).where(status: 1, user_extensions: { identity: 1 })
|
||
|
students = students.where.not(id: params[:student_ids]) if params[:student_ids].present?
|
||
|
students = students.where('LOWER(CONCAT(lastname, firstname, login, nickname)) LIKE ?', "%#{keyword}%")
|
||
|
@students = students.includes(user_extension: :school).limit(20)
|
||
|
|
||
|
# 队员多次报名限制
|
||
|
if current_competition.member_multiple_limited?
|
||
|
ids = @students.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
|