Compare commits

...

2 Commits

Author SHA1 Message Date
xxq250 d538219802 fixed 后台查询打榜分和历史 2025-07-31 16:18:28 +08:00
xxq250 f3ca02f92e fixed 后台查询打榜分 2025-07-31 16:04:25 +08:00
4 changed files with 25 additions and 2 deletions

View File

@ -203,6 +203,10 @@ class CompetitionInfosController < ApplicationController
end
def enroll_list
@stage = params[:stage] || params[:ext5]
if @competition_info.identifier.to_s == "zstp2025" && @stage.blank?
@stage = 1
end
competition_users = CompetitionUser.where(competition_info: @competition_info.id).order("updated_at desc")
zones = @competition_info.manager_zones(current_user)
if params[:zone].present?

View File

@ -118,6 +118,11 @@ class CompetitionUser < ApplicationRecord
competition_user_scores.blank? ? 0 : competition_user_scores.first.score.to_f
end
def max_score_json
competition_user_scores = self.competition_user_scores.where(stage: stage.to_i).order(score: :desc)
competition_user_scores.blank? ? 0 : competition_user_scores.first.score.to_f
end
def stage_api_status(stage)
competition_user_scores = self.competition_user_scores.where(stage: stage.to_i).order(created_at: :desc)
competition_user_scores.blank? ? 0 : competition_user_scores.first.api_status
@ -125,7 +130,7 @@ class CompetitionUser < ApplicationRecord
def stage_api_result_text(stage)
{} if stage_api_status(stage) != 3
api_result = self.competition_user_scores.find_by(stage: stage.to_i)&.api_result
api_result = self.competition_user_scores.where(stage: stage.to_i).order(created_at: :desc).first&.api_result
{} if api_result.blank?
data = JSON.parse api_result
data["msg"].present? ? data["msg"] : data["errorOutput"].present? ? data["errorOutput"] : "系统打分错误,信息不详"
@ -133,6 +138,16 @@ class CompetitionUser < ApplicationRecord
return {}
end
def stage_max_score_data(stage)
{} if stage_api_status(stage) != 3
api_result = self.competition_user_scores.where(stage: stage.to_i).order(score: :desc).first&.api_result
{} if api_result.blank?
data = JSON.parse api_result
data
rescue =>err
return {}
end
def user_login
self.user&.login.to_s
end

View File

@ -10,6 +10,10 @@ json.data do
json.user_real_name c_user.user&.real_name
json.members c_user.members
json.apply_status c_user&.apply_status
json.score @stage.present? ? c_user.stage_score(@stage) : c_user.score
json.last_score @stage.present? ? c_user.stage_last_score(@stage) : c_user.last_score
json.other_score_json @stage.present? ? c_user.stage_max_score_data(@stage) : c_user.last_score
json.history_scores @stage.present? ? c_user.competition_user_scores.to_json : []
json.enroll_template do
file = Attachment.where_id_or_uuid(c_user.enroll_template_id).first
json.partial! 'attachments/attachment_simple', attachment: file if file.present?

View File

@ -11,6 +11,6 @@ json.data do
json.score @stage.present? ? c_user.stage_score(@stage) : c_user.score
json.last_score @stage.present? ? c_user.stage_last_score(@stage) : c_user.last_score
json.other_score_1 c_user.api_result_data["repeatTripleSet"].present? ? c_user.api_result_data["repeatTripleSet"] : 0
json.other_score_json c_user.api_result_data["data"].present? ? c_user.api_result_data["data"] : c_user.api_result_data
json.other_score_json @stage.present? ? c_user.stage_max_score_data(@stage) : c_user.last_score
end
end