MCPcopy Create free account
hub / github.com/github/gh-aw / buildMissingToolsSummary

Function buildMissingToolsSummary

pkg/cli/logs_report_errors.go:65–108  ·  view source on GitHub ↗

buildMissingToolsSummary aggregates missing tools across all runs

(processedRuns []ProcessedRun)

Source from the content-addressed store, hash-verified

63
64// buildMissingToolsSummary aggregates missing tools across all runs
65func buildMissingToolsSummary(processedRuns []ProcessedRun) []MissingToolSummary {
66 reportLog.Printf("Building missing tools summary from %d processed runs", len(processedRuns))
67 result := aggregateSummaryItems(
68 processedRuns,
69 // getItems: extract missing tools from each run
70 func(pr ProcessedRun) []MissingToolReport {
71 return pr.MissingTools
72 },
73 // getKey: use tool name as the aggregation key
74 func(tool MissingToolReport) string {
75 return tool.Tool
76 },
77 // createSummary: create new summary for first occurrence
78 func(tool MissingToolReport) *MissingToolSummary {
79 return &MissingToolSummary{
80 Tool: tool.Tool,
81 AggregatedSummaryBase: AggregatedSummaryBase{
82 Count: 1,
83 Workflows: []string{tool.WorkflowName},
84 FirstReason: tool.Reason,
85 RunIDs: []int64{tool.RunID},
86 },
87 }
88 },
89 // updateSummary: update existing summary with new occurrence
90 func(summary *MissingToolSummary, tool MissingToolReport) {
91 summary.Count++
92 summary.Workflows = sliceutil.MergeUnique(summary.Workflows, tool.WorkflowName)
93 summary.RunIDs = append(summary.RunIDs, tool.RunID)
94 },
95 // finalizeSummary: populate display fields for console rendering
96 func(summary *MissingToolSummary) {
97 summary.WorkflowsDisplay = strings.Join(summary.Workflows, ", ")
98 summary.FirstReasonDisplay = summary.FirstReason
99 },
100 )
101
102 // Sort by count descending
103 slices.SortFunc(result, func(a, b MissingToolSummary) int {
104 return cmp.Compare(b.Count, a.Count)
105 })
106
107 return result
108}
109
110// buildMissingDataSummary aggregates missing data across all runs
111func buildMissingDataSummary(processedRuns []ProcessedRun) []MissingDataSummary {

Calls 3

MergeUniqueFunction · 0.92
aggregateSummaryItemsFunction · 0.85
PrintfMethod · 0.45