|
|
@ -157,12 +157,12 @@ class ChallengesController < ApplicationController
|
|
|
|
uid_logger("identifier: #{params}")
|
|
|
|
uid_logger("identifier: #{params}")
|
|
|
|
base_columns = "challenges.id, challenges.subject, challenges.st, challenges.score, challenges.position,
|
|
|
|
base_columns = "challenges.id, challenges.subject, challenges.st, challenges.score, challenges.position,
|
|
|
|
challenges.shixun_id, games.identifier, games.status"
|
|
|
|
challenges.shixun_id, games.identifier, games.status"
|
|
|
|
|
|
|
|
join_sql = "LEFT JOIN games ON games.challenge_id = challenges.id AND games.user_id = #{current_user.id}"
|
|
|
|
# 下面2个参数是为了解决列表获取通关人数与正在游玩人数的问题
|
|
|
|
# 下面2个参数是为了解决列表获取通关人数与正在游玩人数的问题
|
|
|
|
@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count
|
|
|
|
@pass_games_map = @shixun.challenges.joins(:games).where(games: {status:2}).group(:challenge_id).reorder(nil).count
|
|
|
|
@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count
|
|
|
|
@play_games_map = @shixun.challenges.joins(:games).where(games: {status:[0,1]}).group(:challenge_id).reorder(nil).count
|
|
|
|
|
|
|
|
|
|
|
|
@challenges = @shixun.challenges.joins("left join games on games.challenge_id = challenges.id and games.user_id = #{current_user.id}")
|
|
|
|
@challenges = @shixun.challenges.joins(join_sql).select(base_columns)
|
|
|
|
.select(base_columns)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员
|
|
|
|
@editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员
|
|
|
|
@user = current_user
|
|
|
|
@user = current_user
|
|
|
|