console: ensure main table is used when required even when no data

The user will get empty data, it may be better than an empty table. Add
more tests as well.

Fix #1935
This commit is contained in:
Vincent Bernat
2025-09-04 14:17:23 +02:00
parent 04ce99602f
commit ec3c6e8ffa
3 changed files with 135 additions and 21 deletions

View File

@@ -218,7 +218,7 @@ func (c *Component) computeTableAndInterval(input inputContext) (string, time.Du
// Select table
targetIntervalForTableSelection := targetInterval
if input.MainTableRequired {
targetIntervalForTableSelection = time.Second
return "flows", time.Second, targetInterval
}
startForTableSelection := input.Start
if input.StartForTableSelection != nil {
@@ -269,7 +269,7 @@ func (c *Component) getBestTable(start time.Time, targetInterval time.Duration)
})
// If possible, use the first resolution before the target interval
for len(candidates) > 1 {
if c.flowsTables[candidates[1]].Resolution < targetInterval {
if c.flowsTables[candidates[1]].Resolution <= targetInterval {
candidates = candidates[1:]
} else {
break