86343d286e
build / build (push) Successful in 2m7s
- 请求新增 granularity,看板所有区块统一按所选区间统计(累计量单独保留) - 覆盖率/正确率新增区间严格口径 period_quality,趋势图覆盖整个区间 - 新增环比上一区间条数;卡片标题与统计口径随区间自动生成 - 未传 granularity 时保持原周看板行为不变 (cherry picked from commit fbb1d1d819e7b85ef849e3a1e4ef209707a67b22)
53 lines
1.5 KiB
Go
53 lines
1.5 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"knowledge-governance/internal/dobotaiops"
|
|
"knowledge-governance/internal/qaopsmirror"
|
|
"knowledge-governance/internal/qaopsquality"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type qaDashboardReader interface {
|
|
ReadMasterDashboard(context.Context, dobotaiops.RecordQuery) (qaopsmirror.Dashboard, error)
|
|
}
|
|
|
|
func qaOperationsDashboard(w http.ResponseWriter, r *http.Request, c Config) {
|
|
if !authorizeQAOps(w, r) || !authorizeQAIntent(w, r, "qa-dashboard") {
|
|
return
|
|
}
|
|
var request struct {
|
|
Start string `json:"start"`
|
|
End string `json:"end"`
|
|
Keyword string `json:"keyword"`
|
|
Filters map[string]string `json:"filters,omitempty"`
|
|
Granularity string `json:"granularity,omitempty"`
|
|
}
|
|
if decodeQualityJSON(w, r, &request, "start", "end") != nil {
|
|
qaOpsError(w, dobotaiops.ErrInvalidQuery)
|
|
return
|
|
}
|
|
reader, ok := c.QAOps.(qaDashboardReader)
|
|
if !ok || c.QAOpsTenantKey == "" {
|
|
qaOpsError(w, dobotaiops.ErrUnavailable)
|
|
return
|
|
}
|
|
window, e := dobotaiops.NewWindow(c.QAOpsTenantKey, request.Start, request.End, 90*24*time.Hour, c.Now())
|
|
if e != nil {
|
|
qaOpsError(w, e)
|
|
return
|
|
}
|
|
dashboard, e := reader.ReadMasterDashboard(r.Context(), dobotaiops.RecordQuery{Window: window, Keyword: request.Keyword, Filters: request.Filters, Granularity: request.Granularity})
|
|
if e != nil {
|
|
if errors.Is(e, qaopsquality.ErrConflict) {
|
|
writeQualityError(w, e)
|
|
return
|
|
}
|
|
qaOpsError(w, e)
|
|
return
|
|
}
|
|
writeJSON(w, 200, map[string]any{"data": dashboard})
|
|
}
|