用户通关数

dev_jupyter
daiao 5 years ago
parent ca5602ae08
commit 9657b7065f

@ -143,7 +143,7 @@ class Challenge < ApplicationRecord
# 关卡用户通关数 # 关卡用户通关数
def user_passed_count def user_passed_count
#games.map{|g| g.status == 2}.count #games.map{|g| g.status == 2}.count
self.games.where(status: 1).count self.games.where(status: 2).count
end end
# 关卡用户正在挑战的人数 # 关卡用户正在挑战的人数

@ -20,7 +20,7 @@ if @challenges.present?
user_passed_count = challenge.user_passed_count user_passed_count = challenge.user_passed_count
json.passed_count user_passed_count json.passed_count user_passed_count
#json.playing_count @play_games_map.fetch(challenge.id, 0) #json.playing_count @play_games_map.fetch(challenge.id, 0)
json.playing_count (challenge.playing_count) json.playing_count (challenge.games.count - user_passed_count)
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier) json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.open_game challenge.open_game(@shixun) json.open_game challenge.open_game(@shixun)
#json.open_game challenge.open_game(@shixun, @user.id) #json.open_game challenge.open_game(@shixun, @user.id)

Loading…
Cancel
Save