@records=CompetitionTeam.find_by_sql("SELECT teams.*, cs.score AS s_score, cs.cost_time AS s_spend_time FROM competition_teams teams, competition_scores cs WHERE cs.competition_team_id = teams.`id` AND cs.competition_stage_id = '#{@stage.id}'")
@team_members=@team_members.where("user_extensions.school_id in #{school_ids} and schools.province like '%#{location}%'")
@team_members=@team_members.includes(user:{user_extensions::school}).where("user_extensions.school_id in #{school_ids} and schools.province like '%#{location}%'")
user=User.find_by_sql("SELECT u.* FROM `users` u, `user_extensions` ue where u.id = ue.user_id and ue.identity = 1 and ue.student_id = '#{list[0]}' and ue.school_id= #{school_id.to_i}").first
@ -126,21 +126,26 @@ class SchoolController < ApplicationController
chinese<<char
end
end
ifpinyin.size>0
search_str="name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'"
else
search_str="name like '%#{chinese.join("")}%'"
end
ifparams[:no_school_ids]
if(condition=='')
@school=School.where("id not in #{params[:no_school_ids]}").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.count
else
@school=School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
@school=School.where("id not in #{params[:no_school_ids]} and #{search_str}").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("id not in #{params[:no_school_ids]} and #{search_str}").count
end
else
if(condition=='')
@school=School.reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.count
else
@school=School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
@school=School.where(search_str).reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
relations=EcGraduationRequirementCalculation.joins(ec_course_support::ec_graduation_subitem_courses).where('ec_graduation_subitem_id in (?)',subitem_ids)
@ -129,7 +129,8 @@ class Myshixun < ActiveRecord::Base
ifcurrent_game.blank?
current_game=Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and g.challenge_id = c.id and g.status = 2 order by c.position desc").first
# current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and g.challenge_id = c.id and g.status = 2 order by c.position desc").first