From 3a9866943e4b04264606be6bcce4602c8a3adf50 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Thu, 14 Mar 2019 14:25:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=B5=8B=E8=AF=95=E9=9B=86?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/games_service.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 039d90c8..c87c0e0e 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -88,15 +88,20 @@ class GamesService # tpm_script_modified = (shixun.reset_time > myshixun.reset_time ? true : false) # 新结构脚本是实时传送的,所以不会影响 # 区分评测过未评测过,未评测过按需求取数据 - if max_query_index > 0 - qurey_test_sets = TestSet.find_by_sql("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 outputs o,games g ,challenges c,test_sets t 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 - ") - else - qurey_test_sets = TestSet.find_by_sql("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 + 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" + else + "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 + qurey_test_sets = TestSet.find_by_sql(sql) # 测试集统计及处理 unless qurey_test_sets.blank?