From a4521300a5deff9a49d265596bd2e2f7d80b4f54 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 24 May 2017 20:22:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A6=96=E9=A1=B5=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E4=BF=AE=E6=AD=A3=EF=BC=9A=E6=94=B9=E4=B8=BA=E5=9C=A8?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=9A=84=E5=AE=9E=E8=AE=AD=E4=B8=AD=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- app/controllers/shixuns_controller.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 85041be40..d76494716 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -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) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 178c6c7a4..00b8c9b58 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -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