diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 7e7b6e082..41af7ae68 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -501,6 +501,7 @@ class GamesController < ApplicationController # 编程题评测 def game_build + sec_key = params[:sec_key] game_challenge = Challenge.select([:id, :position, :picture_path]).find(@game.challenge_id) # 更新评测次数 @@ -548,7 +549,7 @@ class GamesController < ApplicationController :instanceChallenge => "#{step}", :testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => @shixun.webssh, :content_modified => content_modified, :containers => "#{Base64.urlsafe_encode64(shixun_container_limit(@shixun))}", - :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", + :persistenceName => @shixun.identifier, :tpmScript => "#{tpmScript}", :sec_key => sec_key, :timeLimit => "#{@shixun.exec_time}", :isPublished => (@shixun.status < 2 ? 0 : 1) } # 评测有文件输出的需要特殊传字段 path:表示文件存储的位置 diff --git a/app/controllers/gits_controller.rb b/app/controllers/gits_controller.rb index f00245190..1965f61ba 100644 --- a/app/controllers/gits_controller.rb +++ b/app/controllers/gits_controller.rb @@ -1,10 +1,15 @@ class GitsController < ApplicationController - #供git-workhorse反向调用认证 + # 说明: + # 以下Git认证只针对新版git,Gitlab的Git认证不走该控制器 + # 思路: + # 1、用户通过Git客户端推送代码的时候,这个时候Git客户端肯定会强制用户输入邮箱的 + # 2、通过web端版本库界面更新代码(如果用户邮箱不存在,则用系统备用邮箱) + # 供 git-workhorse反向调用认证 def auth # HTTP_AUTHORIZATION: "Basic 这里base64编码的的密码(user:passwd)" logger.info("11111112222223333 HTTP_AUTHORIZATION: #{request.env["HTTP_AUTHORIZATION"]}") - #logger.info("#########-----request_env: #{request.env}") + # logger.info("#########-----request_env: #{request.env}") # {"service"=>"git-receive-pack", "controller"=>"gits", "action"=>"auth", # "url"=>"forge01/cermyt39.git/info/refs"} # diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 3abc71fd0..499612167 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -85,9 +85,6 @@ class MyshixunsController < ApplicationController # "createPod":"1.610","evaluateAllTime":2820,"evaluateStart":"2017-11-24 11:04:35","execute":"0.294"}' # params[:pics] = "a.png,b.png,c.png" def training_task_status - logger.info("123################{params[:jsonTestDetails]}") - logger.info("456################{params[:timeCost]}") - logger.info("666###############{params}") ActiveRecord::Base.transaction do begin @@ -98,13 +95,14 @@ class MyshixunsController < ApplicationController return_back_time = format("%.3f", ( t1.to_f - brige_end_time.to_f)).to_f status = jsonTestDetails['status'] game_id = jsonTestDetails['buildID'] + sec_key = jsonTestDetails['sec_key'] logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) jenkins_testsets = jsonTestDetails['msg'] compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? - logger.info(outPut) + game = Game.find(game_id) myshixun = game.myshixun challenge = game.challenge @@ -125,7 +123,7 @@ class MyshixunsController < ApplicationController logger.info "actual_output:################################################# #{actual_output}" Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index, - :compile_success => compile_success.to_i) + :compile_success => compile_success.to_i, :sec_key => sec_key) # 如果设置了按测试集给分,则需要统计测试集的分值 if challenge.test_set_score && j_test_set['passed'].to_i == 1 test_set_score += challenge.test_sets.where(:position => j_test_set['caseId']).pluck(:score).first diff --git a/db/migrate/20190705085829_add_sec_key_to_outputs.rb b/db/migrate/20190705085829_add_sec_key_to_outputs.rb new file mode 100644 index 000000000..428fbaced --- /dev/null +++ b/db/migrate/20190705085829_add_sec_key_to_outputs.rb @@ -0,0 +1,5 @@ +class AddSecKeyToOutputs < ActiveRecord::Migration[5.2] + def change + add_column :outputs, :sec_key, :string + end +end