挑战数和调试数

newyslclassrooms
daiao 5 years ago
parent 6270a90b0b
commit 57cafc1dd4

@ -157,8 +157,10 @@ 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"
@challenges = @shixun.challenges.joins(:games).where(games: {user_id: current_user.id})
.select(base_columns)
# 方便列表获取通关数
@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
@shixun.increment!(:visits)

@ -16,8 +16,8 @@ if @challenges.present?
json.st challenge.st
json.name challenge.subject
json.score challenge.score
json.passed_count challenge.user_passed_count
json.playing_count challenge.playing_count
json.passed_count @pass_games_map.fetch(challenge.id, 0)
json.playing_count @play_games_map.fetch(challenge.id, 0)
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.open_game challenge.open_game
if @editable

Loading…
Cancel
Save