diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 3a49f4d80..ecbf603b0 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -855,7 +855,7 @@ class GamesController < ApplicationController if max_query_index > 0 uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}") - @qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.test_set_position, o.ts_time, + @qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.test_set_position, o.ts_time, o.ts_mem, o.query_index, t.is_public, t.input, t.output, o.compile_success FROM outputs o, games g, challenges c, test_sets t where g.id=#{@game.id} and c.id=#{challenge.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index cb31f2464..0a19f1c08 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -104,10 +104,7 @@ class MyshixunsController < ApplicationController 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']) - # 资源消耗 - uid_logger("##########!!!!!!#{jsonTestDetails['resUsage']}") - max_mem = tran_base64_decode64(jsonTestDetails['resUsage']) if jsonTestDetails['resUsage'].present? - uid_logger("##########!!!!!!#{max_mem}") + jenkins_testsets = jsonTestDetails['msg'] compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? @@ -132,10 +129,12 @@ class MyshixunsController < ApplicationController # is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public) logger.info "actual_output:################################################# #{actual_output}" - ts_time = format("%.3f", j_test_set['testSetTime'].to_i).to_f + ts_time = format("%.2f", j_test_set['testSetTime'].to_f/1000000000).to_f + ts_mem = format("%.2f", j_test_set['testSetMem'].to_f/1024/1024).to_f + 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, :sec_key => sec_key, :ts_time => j_test_set['testSetTime']) + :compile_success => compile_success.to_i, :sec_key => sec_key, :ts_time => ts_time, :ts_mem => ts_mem) # 如果设置了按测试集给分,则需要统计测试集的分值 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 @@ -203,9 +202,9 @@ class MyshixunsController < ApplicationController test_cases_time = format("%.3f", (Time.now.to_f - t1.to_f)).to_f if record.present? consume_time = format("%.3f", (Time.now - record.created_at)).to_f - uid_logger("11122233334444#{max_mem}, #{sec_key}") + record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], - :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :max_mem => max_mem, + :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end uid_logger("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") diff --git a/app/views/games/_testset_list.json.jbuilder b/app/views/games/_testset_list.json.jbuilder index e5cc76625..cef29997b 100644 --- a/app/views/games/_testset_list.json.jbuilder +++ b/app/views/games/_testset_list.json.jbuilder @@ -8,6 +8,7 @@ json.test_sets @qurey_test_sets do |test_set| end json.compile_success test_set.try(:compile_success) json.ts_time test_set.try(:ts_time) + json.ts_time test_set.try(:ts_mem) end json.allowed_unlock @shixun.test_set_permission diff --git a/db/migrate/20190718100242_add_ts_mem_to_outputs.rb b/db/migrate/20190718100242_add_ts_mem_to_outputs.rb new file mode 100644 index 000000000..8a603d7be --- /dev/null +++ b/db/migrate/20190718100242_add_ts_mem_to_outputs.rb @@ -0,0 +1,5 @@ +class AddTsMemToOutputs < ActiveRecord::Migration[5.2] + def change + # add_column :outputs, :ts_mem, :float + end +end