|
|
|
@ -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|
|
|
|
|
|