commit
All checks were successful
Deploy to Server / deploy (push) Successful in 27s

This commit is contained in:
jeremygan2021
2026-03-11 23:04:37 +08:00
parent 8b11d0aab1
commit d28ecf98ea
6 changed files with 49 additions and 11 deletions

View File

@@ -205,24 +205,34 @@ class BailianService:
# 3. 同步评分 (Score)
if evaluation.score is not None:
# 尝试找到匹配的维度
# 优先级:完全匹配模板名称 > 包含"AI"的维度 > 第一个维度
dimensions = competition.score_dimensions.all()
target_dimension = None
for dim in dimensions:
if dim.name == template_name:
target_dimension = dim
break
# 0. 优先使用模板配置的维度
if evaluation.template and evaluation.template.score_dimension:
# 检查配置的维度是否属于当前比赛
if evaluation.template.score_dimension.competition_id == competition.id:
target_dimension = evaluation.template.score_dimension
else:
# 如果不属于当前比赛(跨比赛复用模板),尝试查找同名维度
target_dimension = dimensions.filter(name=evaluation.template.score_dimension.name).first()
# 1. 如果未配置或未找到,尝试匹配 "AI Rating" (用户指定默认值)
if not target_dimension:
target_dimension = dimensions.filter(name__iexact="AI Rating").first()
# 2. 尝试匹配包含 "AI" 的维度
if not target_dimension:
for dim in dimensions:
if "AI" in dim.name.upper():
target_dimension = dim
break
# 3. 尝试匹配模板名称
if not target_dimension:
target_dimension = dimensions.filter(name=template_name).first()
# 如果还是没找到,尝试创建一个默认的 "AI评分" 维度?
# 或者使用第一个维度。考虑到用户说"对应的AI评分",如果没有对应的,可能需要创建一个?
# 为了安全起见如果找不到明确的AI维度且存在维度就用第一个否则不评分。
# 4. 最后兜底:使用第一个维度
if not target_dimension and dimensions.exists():
target_dimension = dimensions.first()