From 6c8517812e4925c6b744540e4ca18f764b957615 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 27 Mar 2019 14:10:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixuns_service.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index 9ec28539..dd898cf6 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -129,9 +129,8 @@ class ShixunsService game_url = if manager position = d.position.nil? ? 1 : d.position - challenge_id = dis.challenges.where(position: position).pluck(:id).first - game_identifier = Game.where(user_id: current_user, - challenge_id: challenge_id).pluck(:identifier).first + game_identifier = Game.find_by_sql("SELECT g.identifier FROM games g JOIN challenges c on g.challenge_id = c.id + WHERE c.shixun_id = #{dis.id} AND c.position = #{position} AND g.user_id = #{current_user.id}").first.try(:identifier) "/tasks/#{game_identifier}" else ""