forked from Gitlink/forgeplus
fixed 后台查询打榜分和历史
This commit is contained in:
parent
f3ca02f92e
commit
d538219802
|
@ -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
|
||||
|
|
|
@ -12,7 +12,8 @@ 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 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
|
||||
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?
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue