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