00c4c13283
build / build (push) Successful in 1m19s
列表正文改为按需读取;保留完整导出、版本隔离和有效标签筛选。 验证:前端全量、Go全量及隔离PG全mirror竞态通过;覆盖首批回调、续载失败与筛选分页。
52 lines
1.4 KiB
Go
52 lines
1.4 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"`
|
|
}
|
|
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})
|
|
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})
|
|
}
|