实训首页统计修正:改为在验证的实训中统计情况

This commit is contained in:
huang 2017-05-24 20:22:52 +08:00
parent f253618426
commit a4521300a5
2 changed files with 5 additions and 3 deletions

View File

@ -29,7 +29,7 @@ class MyshixunsController < ApplicationController
params = {:jobName => "#{myshixun_job}"}
uri = URI("#{jenkins_shixuns}/jenkins-exec/game/deleteJob")
res = uri_exec uri, params
if (res && res['code'] != 0)
if (res && res['code'] != 0 && res['code'] != 1)
raise("实训云平台繁忙繁忙等级89")
end
redirect_to shixun_exec_shixun_path(shixun)

View File

@ -29,8 +29,10 @@ class ShixunsController < ApplicationController
def index
@shixuns = Shixun.where(:authentication => 1).order('updated_at desc')
@shixun_my_score = Game.where(:user_id => User.current).sum(:final_score)
@current_user_had_passed = Myshixun.where(:status => 1).count
@shixun_my_score = Game.find_by_sql("select sum(final_score) as score from games where myshixun_id in (select id from myshixuns where status =1
and user_id=#{User.current.id} and shixun_id in (SELECT id FROM `shixuns` where authentication=1))").first.try(:score).to_i
@current_user_had_passed = Myshixun.find_by_sql("select count(*) as had_passed from myshixuns where status =1 and user_id=#{User.current.id}
and shixun_id in (SELECT id FROM `shixuns` where authentication=1)").first.try(:had_passed).to_i
@shixuns_count = @shixuns.count
render :layout => "base_edu"
end