@@ -37,8 +37,10 @@ type templateHeatmapRow struct {
37
37
}
38
38
39
39
type templateHeatmap struct {
40
- Root * templateHeatmapRow
41
- Periods []string
40
+ Root * templateHeatmapRow
41
+ Periods []string
42
+ Subsystems []string
43
+ Managers []string
42
44
}
43
45
44
46
func (thm * templateHeatmapRow ) addParts (depth int , pathLeft []string , filePath string , instrumented , covered int64 ,
@@ -188,17 +190,17 @@ where
188
190
return stmt
189
191
}
190
192
191
- func filesCoverageWithDetails (ctx context.Context , projectID , ns , subsystem , manager string ,
192
- timePeriods []coveragedb. TimePeriod ) ([]* fileCoverageWithDetails , error ) {
193
+ func filesCoverageWithDetails (ctx context.Context , projectID string , scope * SelectScope ,
194
+ ) ([]* fileCoverageWithDetails , error ) {
193
195
client , err := spannerclient .NewClient (ctx , projectID )
194
196
if err != nil {
195
197
return nil , fmt .Errorf ("spanner.NewClient() failed: %s" , err .Error ())
196
198
}
197
199
defer client .Close ()
198
200
199
201
res := []* fileCoverageWithDetails {}
200
- for _ , timePeriod := range timePeriods {
201
- stmt := filesCoverageWithDetailsStmt (ns , subsystem , manager , timePeriod )
202
+ for _ , timePeriod := range scope . Periods {
203
+ stmt := filesCoverageWithDetailsStmt (scope . Ns , scope . Subsystem , scope . Manager , timePeriod )
202
204
iter := client .Single ().Query (ctx , stmt )
203
205
defer iter .Stop ()
204
206
for {
@@ -243,19 +245,28 @@ func stylesBodyJSTemplate(templData *templateHeatmap,
243
245
template .HTML (js .Bytes ()), nil
244
246
}
245
247
246
- func DoHeatMapStyleBodyJS (ctx context.Context , projectID , ns , subsystem , manager string ,
247
- periods []coveragedb.TimePeriod ) (template.CSS , template.HTML , template.HTML , error ) {
248
- covAndDates , err := filesCoverageWithDetails (ctx , projectID , ns , subsystem , manager , periods )
248
+ type SelectScope struct {
249
+ Ns string
250
+ Subsystem string
251
+ Manager string
252
+ Periods []coveragedb.TimePeriod
253
+ }
254
+
255
+ func DoHeatMapStyleBodyJS (ctx context.Context , projectID string , scope * SelectScope , sss , managers []string ,
256
+ ) (template.CSS , template.HTML , template.HTML , error ) {
257
+ covAndDates , err := filesCoverageWithDetails (ctx , projectID , scope )
249
258
if err != nil {
250
259
return "" , "" , "" , fmt .Errorf ("failed to filesCoverageWithDetails: %w" , err )
251
260
}
252
261
templData := filesCoverageToTemplateData (covAndDates )
262
+ templData .Subsystems = sss
263
+ templData .Managers = managers
253
264
return stylesBodyJSTemplate (templData )
254
265
}
255
266
256
- func DoSubsystemsHeatMapStyleBodyJS (ctx context.Context , projectID , ns , subsystem , manager string ,
257
- periods []coveragedb. TimePeriod ) (template.CSS , template.HTML , template.HTML , error ) {
258
- covWithDetails , err := filesCoverageWithDetails (ctx , projectID , ns , subsystem , manager , periods )
267
+ func DoSubsystemsHeatMapStyleBodyJS (ctx context.Context , projectID string , scope * SelectScope , sss , managers [] string ,
268
+ ) (template.CSS , template.HTML , template.HTML , error ) {
269
+ covWithDetails , err := filesCoverageWithDetails (ctx , projectID , scope )
259
270
if err != nil {
260
271
panic (err )
261
272
}
@@ -274,6 +285,7 @@ func DoSubsystemsHeatMapStyleBodyJS(ctx context.Context, projectID, ns, subsyste
274
285
}
275
286
}
276
287
templData := filesCoverageToTemplateData (ssCovAndDates )
288
+ templData .Managers = managers
277
289
return stylesBodyJSTemplate (templData )
278
290
}
279
291
0 commit comments