列表正文改为按需读取;保留完整导出、版本隔离和有效标签筛选。 验证:前端全量、Go全量及隔离PG全mirror竞态通过;覆盖首批回调、续载失败与筛选分页。
This commit is contained in:
@@ -69,6 +69,20 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 20*time.Second)
|
||||
defer cancel()
|
||||
if !dobotaiops.ValidQualityFilters(q.Filters) {
|
||||
return out, dobotaiops.ErrInvalidQuery
|
||||
}
|
||||
if len(q.Filters) > 0 {
|
||||
if !master {
|
||||
return out, dobotaiops.ErrInvalidQuery
|
||||
}
|
||||
var err error
|
||||
q, err = s.resolveMasterFilters(ctx, q)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
out.Filters = q.Filters
|
||||
}
|
||||
tx, e := s.pool.BeginTx(ctx, pgx.TxOptions{IsoLevel: pgx.RepeatableRead, AccessMode: pgx.ReadOnly})
|
||||
if e != nil {
|
||||
return out, dobotaiops.ErrUnavailable
|
||||
@@ -107,7 +121,12 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
totalSQL = strings.ReplaceAll(totalSQL, "qa_ops_mirror_records", "qa_ops_master_read_model")
|
||||
totalSQL = strings.ReplaceAll(totalSQL, "lower(question)", "lower(question||E'\\n'||chinese_question||E'\\n'||COALESCE(ai_fields->>'question_chinese',''))")
|
||||
}
|
||||
if e = tx.QueryRow(ctx, totalSQL, s.tenant, q.Window.End, q.Keyword).Scan(&out.TotalIssues, &first); e != nil {
|
||||
totalArgs := []any{s.tenant, q.Window.End, q.Keyword}
|
||||
if q.MatchIDs != nil {
|
||||
totalSQL += " AND id=ANY($4::text[])"
|
||||
totalArgs = append(totalArgs, q.MatchIDs)
|
||||
}
|
||||
if e = tx.QueryRow(ctx, totalSQL, totalArgs...).Scan(&out.TotalIssues, &first); e != nil {
|
||||
return out, dobotaiops.ErrUnavailable
|
||||
}
|
||||
lower := q.Window.Start
|
||||
@@ -123,7 +142,12 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
rowsSQL = strings.ReplaceAll(rowsSQL, "SELECT id,asked_at,identity,quality_hash FROM", "SELECT id,asked_at,identity,quality_hash,effective_fields,coverage_result,inline_fields,current_feedback FROM")
|
||||
rowsSQL = strings.ReplaceAll(rowsSQL, "lower(question)", "lower(question||E'\\n'||chinese_question||E'\\n'||COALESCE(ai_fields->>'question_chinese',''))")
|
||||
}
|
||||
rows, e := tx.Query(ctx, rowsSQL, s.tenant, lower, q.Window.End, q.Keyword)
|
||||
rowsArgs := []any{s.tenant, lower, q.Window.End, q.Keyword}
|
||||
if q.MatchIDs != nil {
|
||||
rowsSQL = strings.Replace(rowsSQL, " ORDER BY id LIMIT", " AND id=ANY($5::text[]) ORDER BY id LIMIT", 1)
|
||||
rowsArgs = append(rowsArgs, q.MatchIDs)
|
||||
}
|
||||
rows, e := tx.Query(ctx, rowsSQL, rowsArgs...)
|
||||
if e != nil {
|
||||
return out, dobotaiops.ErrUnavailable
|
||||
}
|
||||
@@ -254,7 +278,7 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
}
|
||||
}
|
||||
}
|
||||
if first != nil {
|
||||
if first != nil && len(q.Filters) == 0 {
|
||||
snapshots, err := s.readFrozenDashboard(ctx, tx, q.Keyword, q.Window.End)
|
||||
if err != nil {
|
||||
return out, err
|
||||
@@ -269,6 +293,15 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
if len(q.Filters) > 0 {
|
||||
filtered := make([]dashboardTimedQuality, 0)
|
||||
for _, row := range timeline {
|
||||
if matchesMasterFilters(row.view, q.Filters) {
|
||||
filtered = append(filtered, row)
|
||||
}
|
||||
}
|
||||
timeline = filtered
|
||||
}
|
||||
out.CumulativeWeeks = dashboardCumulativeFromTimeline(timeline, q.Window.End, calculated)
|
||||
month, cutoff := dashboardQualityMonth(out.WeekStart, q.Window.End, calculated)
|
||||
out.QualityPeriod = &DashboardQualityPeriod{Month: month.Format("2006-01"), Start: month, CutoffAt: cutoff, CalculatedAt: calculated, Source: dashboardMonthlySource, PolicyVersion: dashboardMonthlyPolicy}
|
||||
@@ -279,10 +312,17 @@ func (s *Store) readDashboard(ctx context.Context, q dobotaiops.RecordQuery, mas
|
||||
out.CumulativeWeeks = []DashboardCumulative{}
|
||||
out.CalendarMonths = []DashboardMonth{}
|
||||
}
|
||||
out.ReportedWeeks, e = s.readReportedDashboard(ctx, tx, q.Keyword, q.Window.End)
|
||||
if len(q.Filters) == 0 {
|
||||
out.ReportedWeeks, e = s.readReportedDashboard(ctx, tx, q.Keyword, q.Window.End)
|
||||
} else {
|
||||
out.ReportedWeeks = []DashboardReported{}
|
||||
}
|
||||
if e != nil {
|
||||
return out, e
|
||||
}
|
||||
if e = s.masterFiltersStillCurrent(ctx, q); e != nil {
|
||||
return out, e
|
||||
}
|
||||
if tx.Commit(ctx) != nil {
|
||||
return out, dobotaiops.ErrUnavailable
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user