From 28dbdd03eef8aa87b78382c636adbe1a830db88e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:21:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/myshixun.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..b5bbdc249 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,20 +56,13 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first + games = self.games + current_game = games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? - if self.status == 1 - logger.info("@3333333333344444444#{self.id}") - current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and - g.challenge_id = c.id and g.status = 2 order by c.position desc").first - else - # 如果没开启过的,status都为3,所以应该进入第一关 - current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and - g.challenge_id = c.id and g.status = 3 order by c.position asc").first - end + current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} + and g.challenge_id = c.id and g.status = 2 order by c.position desc").first end - return current_game + current_game end