fixed 后台查询打榜分和历史显示

This commit is contained in:
xxq250 2025-07-31 16:52:56 +08:00
parent 27dce6e202
commit d9d3dfaa8a
4 changed files with 12 additions and 13 deletions

View File

@ -141,8 +141,7 @@ class CompetitionUser < ApplicationRecord
def stage_max_score_data(stage)
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["data"]
api_result["data"]
rescue =>err
return {}
end

View File

@ -4,17 +4,17 @@ class CompetitionUserScore < ApplicationRecord
serialize :api_result, JSON
def api_result_text
"" if self.api_status != 3 || self.api_result.blank?
data = JSON.parse self.api_result
data["msg"].present? ? data["msg"] : data["errorOutput"].present? ? data["errorOutput"] : "系统打分错误,信息不详"
rescue =>err
return nil
end
# def api_result_text
# "" if self.api_status != 3 || self.api_result.blank?
# data = JSON.parse self.api_result
# data["msg"].present? ? data["msg"] : data["errorOutput"].present? ? data["errorOutput"] : "系统打分错误,信息不详"
# rescue =>err
# return nil
# end
def api_result_data
{} if self.api_status != 3 || self.api_result.blank?
data = JSON.parse self.api_result
data = api_result["data"]
data
rescue =>err
return {}

View File

@ -12,9 +12,9 @@ json.data do
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)["data"].present? ? c_user.stage_max_score_data(@stage)["data"] : c_user.api_result_data
json.other_score_json @stage.present? && c_user.stage_max_score_data(@stage).present? ? c_user.stage_max_score_data(@stage): c_user.api_result_data
json.history_scores c_user.competition_user_scores do |user_score|
json.score user_score.api_result
json.score user_score.api_result_data
end
json.enroll_template do
file = Attachment.where_id_or_uuid(c_user.enroll_template_id).first

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 @stage.present? && c_user.stage_max_score_data(@stage)["data"].present? ? c_user.stage_max_score_data(@stage)["data"] : c_user.api_result_data
json.other_score_json @stage.present? && c_user.stage_max_score_data(@stage).present? ? c_user.stage_max_score_data(@stage) : c_user.api_result_data
end
end