From e1864ea2f5fb92b75f35410afb2bb84deadbed25 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 10 Jul 2019 10:45:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A0=87=E7=AD=BE=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/shixun.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 4a4aea355..cb305efaf 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -73,9 +73,8 @@ class Shixun < ApplicationRecord # 实训用户tag def user_tags_name(user = User.current) - challenge_ids = challenges.pluck(:id) - user_challenge_ids = user.games.where(challenge_id: challenge_ids, status: 2).pluck(:challenge_id) - ChallengeTag.where(challenge_id: user_challenge_ids).pluck(:name).uniq + Shixun.joins(challenges: [:challenge_tags, :games]).where(games: {status: 2, user_id: user.id}, shixuns: {id:id}) + .pluck("challenge_tags.name").uniq end # 实训关卡tag @@ -159,7 +158,6 @@ class Shixun < ApplicationRecord # return [实训评分, 5星评分比例, 4星评分比例, 3星评分比例, 2星评分比例, 1星评分比例] def shixun_preference_info game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star) - star_info = [] if game_star_info.present? 5.downto(1) do |i|