diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 4a95e8ab6..164162fd6 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -157,9 +157,9 @@ class ChallengesController < ApplicationController uid_logger("identifier: #{params}") base_columns = "challenges.id, challenges.subject, challenges.st, challenges.score, challenges.position, challenges.shixun_id, games.identifier, games.status" - # 方便列表获取通关数 - @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 + # 方便列表获取通关数和游玩数 + #@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 @challenges = @shixun.challenges.joins(:games).where(games: {user_id: current_user.id}).select(base_columns) @editable = @shixun.status == 0 # before_action:有判断权限,如果没发布,则肯定是管理人员 @user = current_user diff --git a/app/views/challenges/index.json.jbuilder b/app/views/challenges/index.json.jbuilder index ddf75c833..87c6491bb 100644 --- a/app/views/challenges/index.json.jbuilder +++ b/app/views/challenges/index.json.jbuilder @@ -16,8 +16,10 @@ if @challenges.present? json.st challenge.st json.name challenge.subject json.score challenge.score - json.passed_count @pass_games_map.fetch(challenge.id, 0) - json.playing_count @play_games_map.fetch(challenge.id, 0) + #json.passed_count @pass_games_map.fetch(challenge.id, 0) + json.passed_count challenge.user_passed_count + #json.playing_count @play_games_map.fetch(challenge.id, 0) + json.playing_count challenge.playing_count json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.open_game challenge.open_game if @editable