|
|
@ -73,9 +73,8 @@ class Shixun < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
|
|
# 实训用户tag
|
|
|
|
# 实训用户tag
|
|
|
|
def user_tags_name(user = User.current)
|
|
|
|
def user_tags_name(user = User.current)
|
|
|
|
challenge_ids = challenges.pluck(:id)
|
|
|
|
Shixun.joins(challenges: [:challenge_tags, :games]).where(games: {status: 2, user_id: user.id}, shixuns: {id:id})
|
|
|
|
user_challenge_ids = user.games.where(challenge_id: challenge_ids, status: 2).pluck(:challenge_id)
|
|
|
|
.pluck("challenge_tags.name").uniq
|
|
|
|
ChallengeTag.where(challenge_id: user_challenge_ids).pluck(:name).uniq
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 实训关卡tag
|
|
|
|
# 实训关卡tag
|
|
|
@ -159,7 +158,6 @@ class Shixun < ApplicationRecord
|
|
|
|
# return [实训评分, 5星评分比例, 4星评分比例, 3星评分比例, 2星评分比例, 1星评分比例]
|
|
|
|
# return [实训评分, 5星评分比例, 4星评分比例, 3星评分比例, 2星评分比例, 1星评分比例]
|
|
|
|
def shixun_preference_info
|
|
|
|
def shixun_preference_info
|
|
|
|
game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star)
|
|
|
|
game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star)
|
|
|
|
|
|
|
|
|
|
|
|
star_info = []
|
|
|
|
star_info = []
|
|
|
|
if game_star_info.present?
|
|
|
|
if game_star_info.present?
|
|
|
|
5.downto(1) do |i|
|
|
|
|
5.downto(1) do |i|
|
|
|
|