From 6b01530ad2785f3483f266683a2d9663b866c079 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Wed, 17 Jul 2019 11:32:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93=E9=97=AE=E9=A2=98=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 3 ++- app/controllers/myshixuns_controller.rb | 8 ++++++-- app/models/evaluate_record.rb | 8 ++++++++ app/models/output.rb | 12 ++++++++++++ db/migrate/20190716062401_add_ts_time_to_outputs.rb | 5 +++++ ...20190716064225_add_max_mem_to_evaluate_records.rb | 5 +++++ 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20190716062401_add_ts_time_to_outputs.rb create mode 100644 db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index c951340f8..107839b31 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -503,6 +503,7 @@ class GamesController < ApplicationController # 监测版本库HEAD是否存在,不存在则取最新的HEAD uri = "#{shixun_tomcat}/bridge/game/check" res = uri_post uri, rep_params + uid_logger("repo_content to bridge: res is #{res}") # res值:0 表示正常;-1表示有错误;-2表示代码版本库没了 if status == 0 && res && (res['code'] == -2 || res['code'] == -1) # 删除不需要的仓库 @@ -512,7 +513,7 @@ class GamesController < ApplicationController uid_logger_error("#{e.message}") end # fork一个新的仓库 - project_fork(@myshixun, @shixun.repo_path, current_user.login) + # project_fork(@myshixun, @shixun.repo_path, current_user.login) end rescue Exception => e uid_logger_error(e.message) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 31395def2..60edb6dcb 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -96,6 +96,10 @@ class MyshixunsController < ApplicationController status = jsonTestDetails['status'] game_id = jsonTestDetails['buildID'] sec_key = jsonTestDetails['sec_key'] + + res_usage = jsonTestDetails['resUsage'] + ts_time = res_usage['test_set_time_1'] + 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']) @@ -191,8 +195,8 @@ 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 - record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , - :create_pod => timeCost['createPod'], :pod_execute => timeCost['execute'], :test_cases => test_cases_time, + record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], + :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :ts_time => ts_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/models/evaluate_record.rb b/app/models/evaluate_record.rb index 451409493..392b12360 100644 --- a/app/models/evaluate_record.rb +++ b/app/models/evaluate_record.rb @@ -1,3 +1,11 @@ +# 字段说明: +# consume_time:总耗时,包括前端发出请求,到最后前端显示效果 +# git_pull:中间层pull代码耗时 +# create_pod:创建pod耗时 +# pod_execute:pod执行时间耗时,也就代码执行耗时,是各个测试集的总耗时 +# test_cases:outpus表中存储及处理测试集的时间耗时 +# brige:中间层总耗时 +# return_back:回调耗时,从中间层发送请求到educoder所耗时间 class EvaluateRecord < ApplicationRecord default_scope { order("evaluate_records.id desc") } belongs_to :game diff --git a/app/models/output.rb b/app/models/output.rb index b813f6070..7a4a22e7e 100644 --- a/app/models/output.rb +++ b/app/models/output.rb @@ -1,3 +1,15 @@ +# 字段说明: +# code:-1表示评测未通过,0表示评测成功,实质是status的值 +# mes: +# out_put: +# test_set_position: 测试集序号(排序) +# actual_output: +# result: +# is_public:测试集是否是公开 +# query_index:评测次数 +# compile_success: +# text_scor: +# sec_key:每次评测的唯一标识 class Output < ApplicationRecord belongs_to :game end diff --git a/db/migrate/20190716062401_add_ts_time_to_outputs.rb b/db/migrate/20190716062401_add_ts_time_to_outputs.rb new file mode 100644 index 000000000..8e0c55a78 --- /dev/null +++ b/db/migrate/20190716062401_add_ts_time_to_outputs.rb @@ -0,0 +1,5 @@ +class AddTsTimeToOutputs < ActiveRecord::Migration[5.2] + def change + add_column :outputs, :ts_time, :float + end +end diff --git a/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb b/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb new file mode 100644 index 000000000..4c9907d0a --- /dev/null +++ b/db/migrate/20190716064225_add_max_mem_to_evaluate_records.rb @@ -0,0 +1,5 @@ +class AddMaxMemToEvaluateRecords < ActiveRecord::Migration[5.2] + def change + add_column :evaluate_records, :max_mem, :float + end +end