From 2a68ed0cb0bd61f672cd1456196774fc2edafed8 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Thu, 14 Mar 2019 15:56:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD.=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E9=9B=86,?= =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E6=88=90=E5=85=B3=E5=8D=A1=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=A0=E6=B3=95=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=9B=86=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index c87c0e0e..a7c77d70 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -90,14 +90,22 @@ class GamesService # 区分评测过未评测过,未评测过按需求取数据 sql = if max_query_index > 0 - "SELECT o.actual_output, o.out_put, o.result, o.test_set_position, o.query_index,t.is_public,t.input, - t.output, g.id as game_id, c.id as challenge_id - FROM test_sets t, outputs o,games g ,challenges c - WHERE g.id=#{game.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 t.position =o.test_set_position - ORDER BY o.query_index" + "SELECT + b.actual_output, b.out_put, b.result, a.is_public, a.input + FROM + (SELECT position, input, challenge_id, is_public FROM test_sets where challenge_id=6000) a + LEFT JOIN + (SELECT + result, test_set_position, g.challenge_id, o.actual_output, o.out_put + FROM + outputs o left join games g on g.id=o.game_id + WHERE + game_id=#{game.id} and query_index = #{max_query_index} + ) b + ON + b.challenge_id = a.challenge_id and b.test_set_position = a.position" else - "SELECT t.is_public,t.input, t.output, t.position + "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" end