func inflateRow()

in pkg/updater/inflate.go [126:186]


func inflateRow(row *statepb.Row) func() *Cell {
	if row == nil {
		return func() *Cell { return nil }
	}
	addCellID := hasCellID(row.Name)

	var filledIdx int
	var mets map[string]func() (*float64, bool)
	if len(row.Metrics) > 0 {
		mets = make(map[string]func() (*float64, bool), len(row.Metrics))
	}
	for i, m := range row.Metrics {
		if m.Name == "" && len(row.Metrics) > i {
			m.Name = row.Metric[i]
		}
		mets[m.Name] = inflateMetric(m)
	}
	var val *float64
	nextResult := inflateResults(row.Results)
	return func() *Cell {
		for cur := nextResult(); cur != nil; cur = nextResult() {
			result := *cur
			c := Cell{
				Result: result,
				ID:     row.Id,
			}
			for name, nextValue := range mets {
				val, _ = nextValue()
				if val == nil {
					continue
				}
				if c.Metrics == nil {
					c.Metrics = make(map[string]float64, 2)
				}
				c.Metrics[name] = *val
			}
			// TODO(fejta): consider returning (nil, true) instead here
			if result != statuspb.TestStatus_NO_RESULT {
				c.Icon = row.Icons[filledIdx]
				c.Message = row.Messages[filledIdx]
				if addCellID {
					c.CellID = row.CellIds[filledIdx]
				}
				if len(row.Properties) != 0 && c.Properties == nil {
					c.Properties = make(map[string]string)
				}
				if filledIdx < len(row.Properties) {
					for k, v := range row.GetProperties()[filledIdx].GetProperty() {
						c.Properties[k] = v
					}
				}
				if n := len(row.UserProperty); n > filledIdx {
					c.UserProperty = row.UserProperty[filledIdx]
				}
				filledIdx++
			}
			return &c
		}
		return nil
	}
}