diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-01-07 20:47:29 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-09 10:20:58 +0000 |
| commit | 7cc17001e974d9ff7d7ce042c4e2ad2e8ec0e55e (patch) | |
| tree | bd76bcfe68cf89381bd61ba5f8036665ad5cd523 /pkg/cover/heatmap.go | |
| parent | 9220929f371b5549fde0c05fdb17e18ec842f077 (diff) | |
dashboard/app: add targeting controls to the coverage page
It allows to control known parameters:
1. Period (months or days).
2. Target subsystem.
3. Target manager.
And adds the disabled "Only unique" checkbox.
Diffstat (limited to 'pkg/cover/heatmap.go')
| -rw-r--r-- | pkg/cover/heatmap.go | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/pkg/cover/heatmap.go b/pkg/cover/heatmap.go index 903294095..b8e3bbfa6 100644 --- a/pkg/cover/heatmap.go +++ b/pkg/cover/heatmap.go @@ -37,8 +37,10 @@ type templateHeatmapRow struct { } type templateHeatmap struct { - Root *templateHeatmapRow - Periods []string + Root *templateHeatmapRow + Periods []string + Subsystems []string + Managers []string } func (thm *templateHeatmapRow) addParts(depth int, pathLeft []string, filePath string, instrumented, covered int64, @@ -188,8 +190,8 @@ where return stmt } -func filesCoverageWithDetails(ctx context.Context, projectID, ns, subsystem, manager string, - timePeriods []coveragedb.TimePeriod) ([]*fileCoverageWithDetails, error) { +func filesCoverageWithDetails(ctx context.Context, projectID string, scope *SelectScope, +) ([]*fileCoverageWithDetails, error) { client, err := spannerclient.NewClient(ctx, projectID) if err != nil { return nil, fmt.Errorf("spanner.NewClient() failed: %s", err.Error()) @@ -197,8 +199,8 @@ func filesCoverageWithDetails(ctx context.Context, projectID, ns, subsystem, man defer client.Close() res := []*fileCoverageWithDetails{} - for _, timePeriod := range timePeriods { - stmt := filesCoverageWithDetailsStmt(ns, subsystem, manager, timePeriod) + for _, timePeriod := range scope.Periods { + stmt := filesCoverageWithDetailsStmt(scope.Ns, scope.Subsystem, scope.Manager, timePeriod) iter := client.Single().Query(ctx, stmt) defer iter.Stop() for { @@ -243,19 +245,28 @@ func stylesBodyJSTemplate(templData *templateHeatmap, template.HTML(js.Bytes()), nil } -func DoHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem, manager string, - periods []coveragedb.TimePeriod) (template.CSS, template.HTML, template.HTML, error) { - covAndDates, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, manager, periods) +type SelectScope struct { + Ns string + Subsystem string + Manager string + Periods []coveragedb.TimePeriod +} + +func DoHeatMapStyleBodyJS(ctx context.Context, projectID string, scope *SelectScope, sss, managers []string, +) (template.CSS, template.HTML, template.HTML, error) { + covAndDates, err := filesCoverageWithDetails(ctx, projectID, scope) if err != nil { return "", "", "", fmt.Errorf("failed to filesCoverageWithDetails: %w", err) } templData := filesCoverageToTemplateData(covAndDates) + templData.Subsystems = sss + templData.Managers = managers return stylesBodyJSTemplate(templData) } -func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsystem, manager string, - periods []coveragedb.TimePeriod) (template.CSS, template.HTML, template.HTML, error) { - covWithDetails, err := filesCoverageWithDetails(ctx, projectID, ns, subsystem, manager, periods) +func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID string, scope *SelectScope, sss, managers []string, +) (template.CSS, template.HTML, template.HTML, error) { + covWithDetails, err := filesCoverageWithDetails(ctx, projectID, scope) if err != nil { panic(err) } @@ -274,6 +285,7 @@ func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsyste } } templData := filesCoverageToTemplateData(ssCovAndDates) + templData.Managers = managers return stylesBodyJSTemplate(templData) } |
