Skip to content

Commit

Permalink
api: test_details with correct querying for cross-variant
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiouxme committed Aug 21, 2024
1 parent 21fd7fa commit 772cba1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkg/api/componentreadiness/test_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,34 @@ func (c *componentReportGenerator) getTestDetailsQuery(allJobVariants crtype.Job
for group, variant := range c.RequestedVariants {
queryString += fmt.Sprintf(` AND jv_%s.variant_value = '%s'`, api.CleanseSqlName(group), api.CleanseSqlName(variant))
}
if isSample {
queryString += filterByCrossCompareVariants(c.VariantCrossCompare, c.CompareVariants, &commonParams)
} else {
queryString += filterByCrossCompareVariants(c.VariantCrossCompare, c.IncludeVariants, &commonParams)
}
return queryString, groupString, commonParams
}

// filterByCrossCompareVariants adds the where clause for any variants being cross-compared (which are not included in RequiredVariants).
// As a side effect, it also appends any necessary parameters for the clause.
func filterByCrossCompareVariants(crossCompare []string, variantGroups map[string][]string, params *[]bigquery2.QueryParameter) (whereClause string) {
if len(variantGroups) == 0 {
return // avoid possible nil pointer dereference
}
for _, group := range crossCompare {
if variants := variantGroups[group]; len(variants) > 0 {
group = api.CleanseSqlName(group)
paramName := "CrossVariants" + group
whereClause += fmt.Sprintf(` AND jv_%s.variant_value IN UNNEST(@%s)`, group, paramName)
*params = append(*params, bigquery2.QueryParameter{
Name: paramName,
Value: variants,
})
}
}
return
}

type baseJobRunTestStatusGenerator struct {
commonQuery string
groupByQuery string
Expand Down

0 comments on commit 772cba1

Please sign in to comment.