评测添加一些日志

pre_develop
jingquan huang 6 years ago
parent f3f879973d
commit a5d2976f17

@ -801,6 +801,7 @@ class GamesService
# 轮询获取状态 # 轮询获取状态
# resubmit是在file_update中生成的从game_build中传入的 # resubmit是在file_update中生成的从game_build中传入的
def game_status params, current_user def game_status params, current_user
Rails.logger("sec_key is #{params[:sec_key]}**1")
game = Game.find_by_identifier(params[:identifier]) game = Game.find_by_identifier(params[:identifier])
resubmit_identifier = game.resubmit_identifier resubmit_identifier = game.resubmit_identifier
# 如果没有超时并且正在评测中 # 如果没有超时并且正在评测中
@ -812,6 +813,7 @@ class GamesService
return {:running_code_status => running_code_status, :running_code_message => running_code_message} return {:running_code_status => running_code_status, :running_code_message => running_code_message}
end end
Rails.logger("sec_key is #{params[:sec_key]}**2")
Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}") Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}")
port = params[:port] port = params[:port]
score = 0 score = 0
@ -838,6 +840,7 @@ class GamesService
end end
end end
Rails.logger("sec_key is #{params[:sec_key]}**3")
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
max_query_index = game.query_index - 1 max_query_index = game.query_index - 1
# 区分评测过未评测过,未评测过按需求取数据 # 区分评测过未评测过,未评测过按需求取数据
@ -854,7 +857,7 @@ class GamesService
# 能进入到此处肯定是已经返回了结果也就是说outputs中肯定有了数据 # 能进入到此处肯定是已经返回了结果也就是说outputs中肯定有了数据
Rails.logger("sec_key is #{params[:sec_key]}**4")
test_sets_count = qurey_test_sets.size test_sets_count = qurey_test_sets.size
# had_test = Output.where(:game_id => game.id, :query_index => max_query_index) # had_test = Output.where(:game_id => game.id, :query_index => max_query_index)
# had_test_count = had_test.count # had_test_count = had_test.count
@ -881,6 +884,7 @@ class GamesService
web_route = game_challenge.try(:web_route) web_route = game_challenge.try(:web_route)
mirror_name = shixun.mirror_name mirror_name = shixun.mirror_name
Rails.logger("sec_key is #{params[:sec_key]}**5")
# 轮询结束,更新评测耗时 # 轮询结束,更新评测耗时
e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first
if game_status == 0 || game_status == 2 if game_status == 0 || game_status == 2
@ -898,12 +902,14 @@ class GamesService
# 实训制作者当前拥有的金币 # 实训制作者当前拥有的金币
grade = User.where(:id => game.user_id).pluck(:grade).first grade = User.where(:id => game.user_id).pluck(:grade).first
Rails.logger("sec_key is #{params[:sec_key]}**6")
# 高性能取上一关、下一关 # 高性能取上一关、下一关
prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position) prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position)
next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier) next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier)
output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count} output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count}
Rails.logger("sec_key is #{params[:sec_key]}**7")
return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done, return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done,
:position => game_challenge.position, :port => port, :power => power, :record => record, :position => game_challenge.position, :port => port, :power => power, :record => record,
:mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output, :mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output,

Loading…
Cancel
Save