From bea1dd618d6d75294137bc66555469b8f2572c70 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 3 Apr 2019 11:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87=E4=BD=86?= =?UTF-8?q?=E6=98=AF=E6=B5=8B=E8=AF=95=E9=9B=86=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index e60ec82d..108cb93e 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -96,7 +96,7 @@ class GamesService (SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=#{game_challenge.id}) a LEFT JOIN (SELECT - result, test_set_position, g.challenge_id, o.actual_output, o.out_put + result, test_set_position, g.challenge_id, o.actual_output, o.out_put, o.compile_success FROM outputs o left join games g on g.id=o.game_id WHERE @@ -105,6 +105,7 @@ class GamesService ON b.challenge_id = a.challenge_id and b.test_set_position = a.position" else + # 这个地方如果加字段的话一定注意test_set_static_data方法,因为这个地方的字段数在下面有判断 "SELECT t.is_public, t.input, t.output, t.position FROM games g ,challenges c,test_sets t WHERE g.id=#{game.id} and c.id= g.challenge_id and t.challenge_id = c.id" @@ -147,12 +148,13 @@ class GamesService test_result = [] unless test_sets.blank? test_sets.each do |test_set| + # 第一次刷新或者没有评测的的时候test_set只需取四个字段,所以取了count actual_output = test_set.attributes.count > 4 ? test_set.try(:actual_output) : nil result = test_set.attributes.count > 4 ? test_set.try(:result) : nil + compile_success = test_set.attributes.count > 4 ? test_set.try(:compile_success) : nil #actual_output = Base64.encode64(actual_output) - compile_success = (actual_output.blank? || actual_output.downcase.match(/error/).present?) ? 0 : 1 - actual_output = (compile_success == 0 ? "编译失败,请在测试结果中查看具体的错误信息" : actual_output) + actual_output = (compile_success.to_s == "0" ? "编译失败,请在测试结果中查看具体的错误信息" : actual_output) public_result = {:is_public => (test_set.is_public ? 1 : 0), :result => result, :actual_output => actual_output, :compile_success => compile_success}