feat(qaops): 看板改用自然月质量指标并增加统计口径
build / build (push) Successful in 1m10s

去掉看板个人月明细;十一卡悬停和键盘可读的真实统计范围、公式与排除数。
自然月独立计算;跨月周取周一所在月,保留旧周证据和已存周报正文。

验证:make verify;一次性PG全镜像套件-race;真实恢复数据7个月与周报calc_metrics对拍。
真实浏览器十一卡逐项悬停、Tab/Escape、30秒刷新、跨月周、390px和完整PNG通过。
没有写DobotAI源问答、触发付费模型、外发或应用新迁移。
This commit is contained in:
姚章浩
2026-10-21 08:48:55 +08:00
parent 1580ebd826
commit cb9f0c389f
24 changed files with 878 additions and 169 deletions
@@ -8,6 +8,34 @@ import (
"time"
)
func TestWeeklyTemplateCalendarMonthOverridesOnlyNewPrefillNotHistoricalEvidence(t *testing.T) {
now := monthlyTestTime(t, "2026-10-21T08:00:00+08:00")
start, end, e := weeklyDraftBounds("2026-W40", now)
if e != nil {
t.Fatal(e)
}
data := Dashboard{Start: start, End: end, MonthStart: monthlyTestTime(t, "2026-10-01T00:00:00+08:00"), ReportedWeeks: []DashboardReported{{Week: "2026WK40", WeekStart: start, WeekEnd: end, CoveragePercent: 57.23, CorrectnessPercent: 92.34, Source: "user_provided_history"}}, QualityPeriod: &DashboardQualityPeriod{Month: "2026-09", Start: monthlyTestTime(t, "2026-09-01T00:00:00+08:00"), CutoffAt: monthlyTestTime(t, "2026-10-01T00:00:00+08:00"), CalculatedAt: now, Source: dashboardMonthlySource, PolicyVersion: dashboardMonthlyPolicy}, MonthlyQuality: &DashboardStrictQuality{Records: 3, Coverage: dashboardRate(2, 3), Correctness: dashboardRate(1, 2)}}
md, seed, e := renderWeeklyTemplate("2026-W40", data, now)
if e != nil {
t.Fatal(e)
}
var meta map[string]any
_ = json.Unmarshal(seed, &meta)
if !strings.Contains(md, "Coverage Rate: 66.67%") || !strings.Contains(md, "Accuracy Rate: 50.00%") || !strings.Contains(md, "质量统计月:2026-09") || meta["quality_source"] != dashboardMonthlySource {
t.Fatal("new weekly prefill still uses historical/week quality instead of the selected calendar month", md)
}
if data.ReportedWeeks[0].CoveragePercent != 57.23 {
t.Fatal("historical reported evidence changed")
}
if strings.Count(md, "\n## ") != 12 {
t.Fatal("changed approved bilingual six-section template")
}
period, ok := meta["quality_period"].(map[string]any)
if !ok || period["month"] != "2026-09" {
t.Fatal("monthly prefill provenance missing")
}
}
func TestWeeklyTemplateHistoricalRatesKeepSourceWeekKeyAndUseMatchingBoundaries(t *testing.T) {
now := time.Date(2026, 10, 19, 12, 0, 0, 0, time.UTC)
start, end, e := weeklyDraftBounds("2026-W40", now)