func gridMetrics()

in pkg/summarizer/summary.go [1092:1157]


func gridMetrics(cols int, rows []*statepb.Row, recent int, brokenThreshold float32, features FeatureFlags, opts *configpb.DashboardTabStatusCustomizationOptions) (gridStats, bool) {
	results := result.Map(rows)
	var passingCells int
	var filledCells int
	var passingCols int
	var completedCols int
	var ignoredCols int
	var brokenState bool

	for idx := 0; idx < cols; idx++ {
		if idx >= recent {
			break
		}
		var passes int
		var failures int
		var ignores int
		var other int
		for _, iter := range results {
			// TODO(fejta): fail old running cols
			r, _ := iter()
			// check for ignores first
			if features.AllowIgnoredColumns && result.Ignored(r, opts) {
				ignores++
			}
			// proceed with the rest of calculations
			status := coalesceResult(r, result.IgnoreRunning)
			if result.Passing(status) {
				passes++
				passingCells++
				filledCells++
			} else if result.Failing(status) {
				failures++
				filledCells++
			} else if status != statuspb.TestStatus_NO_RESULT {
				other++
				filledCells++
			}
		}

		if passes+failures+other > 0 {
			completedCols++
		}
		// only one of those can be true
		if ignores > 0 {
			ignoredCols++
		} else if failures == 0 && passes > 0 {
			passingCols++
		}

		if passes+failures > 0 && brokenThreshold > 0 {
			if float32(failures)/float32(passes+failures+other) > brokenThreshold {
				brokenState = true
			}
		}
	}

	metrics := gridStats{
		passingCols:   passingCols,
		completedCols: completedCols,
		ignoredCols:   ignoredCols,
		passingCells:  passingCells,
		filledCells:   filledCells,
	}

	return metrics, brokenState
}