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

Function aggregateSummaryItems

pkg/cli/logs_report_errors.go:25–55  ·  view source on GitHub ↗

aggregateSummaryItems is a generic helper that aggregates items from processed runs into summaries It handles the common pattern of grouping by key, counting occurrences, tracking unique workflows, and collecting run IDs

(
	processedRuns []ProcessedRun,
	getItems func(ProcessedRun) []TItem,
	getKey func(TItem) string,
	createSummary func(TItem) *TSummary,
	updateSummary func(*TSummary, TItem),
	finalizeSummary func(*TSummary),
)

Source from the content-addressed store, hash-verified

23// aggregateSummaryItems is a generic helper that aggregates items from processed runs into summaries
24// It handles the common pattern of grouping by key, counting occurrences, tracking unique workflows, and collecting run IDs
25func aggregateSummaryItems[TItem any, TSummary any](
26 processedRuns []ProcessedRun,
27 getItems func(ProcessedRun) []TItem,
28 getKey func(TItem) string,
29 createSummary func(TItem) *TSummary,
30 updateSummary func(*TSummary, TItem),
31 finalizeSummary func(*TSummary),
32) []TSummary {
33 summaryMap := make(map[string]*TSummary)
34
35 // Aggregate items from all runs
36 for _, pr := range processedRuns {
37 for _, item := range getItems(pr) {
38 key := getKey(item)
39 if summary, exists := summaryMap[key]; exists {
40 updateSummary(summary, item)
41 } else {
42 summaryMap[key] = createSummary(item)
43 }
44 }
45 }
46
47 // Convert map to slice and finalize each summary
48 var result []TSummary
49 for _, summary := range summaryMap {
50 finalizeSummary(summary)
51 result = append(result, *summary)
52 }
53
54 return result
55}
56
57// buildCombinedErrorsSummary is an intentional no-op compatibility stub retained
58// after error-pattern support was removed.

Callers 4

buildMissingToolsSummaryFunction · 0.85
buildMissingDataSummaryFunction · 0.85
buildMCPFailuresSummaryFunction · 0.85

Calls

no outgoing calls

Tested by 1