score
All checks were successful
Deploy to Server / deploy (push) Successful in 17s

This commit is contained in:
jeremygan2021
2026-03-20 15:22:51 +08:00
parent 06afd11f1c
commit 98baa92e98

View File

@@ -230,6 +230,9 @@ class Project(models.Model):
公式配置模式(使用 ScoreFormula 模型)
使用公式配置中的公式计算得分
变量格式: dimension_X (X为维度ID)
注意:公式中的维度值已经是加权后的分数(原始分数 × 权重)
保存的评分是原始分数(不乘权重),显示时乘以权重
"""
dimension_scores = {}
@@ -238,7 +241,8 @@ class Project(models.Model):
dim_scores = scores.filter(dimension=dimension)
if dim_scores.exists():
avg = sum(float(s.score) for s in dim_scores) / dim_scores.count()
dimension_scores[f'dimension_{dimension.id}'] = avg
weighted_score = avg * float(dimension.weight)
dimension_scores[f'dimension_{dimension.id}'] = weighted_score
else:
dimension_scores[f'dimension_{dimension.id}'] = 0