fix(qa): 无法判定的判错结论不再计入正确率分母
build / build (push) Successful in 1m18s

根因为“结果不清”或未归因的判错记录移出正确率分母,并以 unjudged 单独返回,覆盖率口径不变。
统计规则版本升到 calendar-month-strict-yes-over-yes-no-v2,前端严格解析同步接受该字段。
This commit is contained in:
hermes
2026-10-25 23:11:12 +08:00
parent 1d880a0f49
commit 1d33ff6976
5 changed files with 74 additions and 11 deletions
+21 -1
View File
@@ -2,11 +2,12 @@ package qaopsmirror
import (
"knowledge-governance/internal/qaopsquality"
"strings"
"time"
)
const dashboardMonthlySource = "master_live_calendar_month_v1"
const dashboardMonthlyPolicy = "calendar-month-strict-yes-over-yes-no-v1"
const dashboardMonthlyPolicy = "calendar-month-strict-yes-over-yes-no-v2"
type DashboardQualityPeriod struct {
Month string `json:"month"`
@@ -20,6 +21,7 @@ type DashboardStrictQuality struct {
Records int `json:"records"`
Coverage qaopsquality.Rate `json:"coverage"`
Correctness qaopsquality.Rate `json:"correctness"`
Unjudged int `json:"unjudged"`
}
type DashboardMonth struct {
Month string `json:"month"`
@@ -52,6 +54,14 @@ func dashboardStrictQuality(records []dashboardTimedQuality, start, end time.Tim
case "uncovered":
uncovered++
}
// An answer whose correctness cannot be established is not a wrong answer:
// "结果不清" and a missing root cause both mean the judge could not attribute a
// concrete defect, so they leave the correctness denominator and are surfaced
// separately instead of silently inflating the error count.
if dashboardUnjudged(r.view) {
out.Unjudged++
continue
}
switch r.view.Effective.Correctness {
case "correct":
correct++
@@ -64,6 +74,16 @@ func dashboardStrictQuality(records []dashboardTimedQuality, start, end time.Tim
return out
}
func dashboardUnjudged(v qaopsquality.View) bool {
if v.State == "stale" || v.Effective.Correctness != "incorrect" {
return false
}
cause := strings.TrimSpace(v.Effective.RootCause)
return cause == "" || cause == dashboardUnclearCause
}
const dashboardUnclearCause = "结果不清"
func dashboardCalendarMonths(records []dashboardTimedQuality, end, now time.Time) []DashboardMonth {
out := []DashboardMonth{}
cutoff := end