ソースを参照

feat: add decision summary to refinement API

master
Jan Svabenik 5時間前
コミット
04c188843f
2個のファイルの変更37行の追加7行の削除
  1. +29
    -0
      cmd/sdrd/decision_summary.go
  2. +8
    -7
      cmd/sdrd/http_handlers.go

+ 29
- 0
cmd/sdrd/decision_summary.go ファイルの表示

@@ -0,0 +1,29 @@
package main

import "sdr-wideband-suite/internal/pipeline"

type decisionSummary struct {
Total int `json:"total"`
RecordEnabled int `json:"record_enabled"`
DecodeEnabled int `json:"decode_enabled"`
Reasons map[string]int `json:"reasons,omitempty"`
}

func summarizeDecisions(decisions []pipeline.SignalDecision) decisionSummary {
summary := decisionSummary{Reasons: map[string]int{}}
summary.Total = len(decisions)
for _, d := range decisions {
if d.ShouldRecord {
summary.RecordEnabled++
}
if d.ShouldAutoDecode {
summary.DecodeEnabled++
}
reason := d.Reason
if reason == "" {
reason = "unspecified"
}
summary.Reasons[reason]++
}
return summary
}

+ 8
- 7
cmd/sdrd/http_handlers.go ファイルの表示

@@ -156,13 +156,14 @@ func registerAPIHandlers(mux *http.ServeMux, cfgPath string, cfgManager *runtime
snap := phaseSnap.Snapshot()
windowStats := buildWindowStats(snap.refinementInput.Windows)
out := map[string]any{
"plan": snap.refinementInput.Plan,
"windows": snap.refinementInput.Windows,
"window_stats": windowStats,
"candidates": len(snap.refinementInput.Candidates),
"scheduled": len(snap.refinementInput.Scheduled),
"signals": len(snap.refinement.Signals),
"decisions": len(snap.refinement.Decisions),
"plan": snap.refinementInput.Plan,
"windows": snap.refinementInput.Windows,
"window_stats": windowStats,
"candidates": len(snap.refinementInput.Candidates),
"scheduled": len(snap.refinementInput.Scheduled),
"signals": len(snap.refinement.Signals),
"decisions": len(snap.refinement.Decisions),
"decision_summary": summarizeDecisions(snap.refinement.Decisions),
}
_ = json.NewEncoder(w).Encode(out)
})


読み込み中…
キャンセル
保存