@@ -72,6 +72,21 @@ func NewExptAggrResultService(
7272 }
7373}
7474
75+ // effectiveEvaluatorResultScoreForAggr 返回用于实验聚合统计的分数:Correction.Score 优先(非 nil 时),否则原始 Score。
76+ // 与 expt_result_impl.calculateWeightedScore、CorrectEvaluatorRecord 语义一致。
77+ func effectiveEvaluatorResultScoreForAggr (res * entity.EvaluatorResult ) (float64 , bool ) {
78+ if res == nil {
79+ return 0 , false
80+ }
81+ if res .Correction != nil && res .Correction .Score != nil {
82+ return * res .Correction .Score , true
83+ }
84+ if res .Score != nil {
85+ return * res .Score , true
86+ }
87+ return 0 , false
88+ }
89+
7590func (e * ExptAggrResultServiceImpl ) CreateExptAggrResult (ctx context.Context , spaceID , experimentID int64 ) (err error ) {
7691 now := time .Now ().Unix ()
7792 defer func () { e .metric .EmitCalculateExptAggrResult (spaceID , int64 (entity .CreateAllFields ), err != nil , now ) }()
@@ -122,13 +137,14 @@ func (e *ExptAggrResultServiceImpl) CreateExptAggrResult(ctx context.Context, sp
122137 if ! ok || evalResult == nil {
123138 continue
124139 }
125- if evalResult .EvaluatorOutputData == nil ||
126- evalResult .EvaluatorOutputData .EvaluatorResult == nil ||
127- evalResult .EvaluatorOutputData .EvaluatorResult .Score == nil {
140+ if evalResult .EvaluatorOutputData == nil {
128141 continue
129142 }
130-
131- aggregatorGroup .Append (gptr .Indirect (evalResult .EvaluatorOutputData .EvaluatorResult .Score ))
143+ score , hasScore := effectiveEvaluatorResultScoreForAggr (evalResult .EvaluatorOutputData .EvaluatorResult )
144+ if ! hasScore {
145+ continue
146+ }
147+ aggregatorGroup .Append (score )
132148 }
133149 }
134150 }
@@ -401,12 +417,12 @@ func (e *ExptAggrResultServiceImpl) UpdateExptAggrResult(ctx context.Context, pa
401417
402418 aggregatorGroup := NewAggregatorGroup (WithScoreDistributionAggregator ())
403419 for _ , evalResult := range recordMap {
404- if evalResult .EvaluatorOutputData == nil || evalResult . EvaluatorOutputData . EvaluatorResult == nil {
420+ if evalResult .EvaluatorOutputData == nil {
405421 continue
406422 }
407- score := gptr . Indirect (evalResult .EvaluatorOutputData .EvaluatorResult . Score )
408- if evalResult . EvaluatorOutputData . EvaluatorResult . Correction != nil {
409- score = gptr . Indirect ( evalResult . EvaluatorOutputData . EvaluatorResult . Correction . Score )
423+ score , ok := effectiveEvaluatorResultScoreForAggr (evalResult .EvaluatorOutputData .EvaluatorResult )
424+ if ! ok {
425+ continue
410426 }
411427 aggregatorGroup .Append (score )
412428 }
0 commit comments