fix: ordering of ts and table panel (#3163)

* fix: ordering of ts and table panel

* chore: refactor
This commit is contained in:
Vishal Sharma 2023-07-18 11:01:51 +05:30 committed by GitHub
parent 50142321f7
commit 49afc2549f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4161,7 +4161,7 @@ func readRowsForTimeSeriesResult(rows driver.Rows, vars []interface{}, columnNam
// ("order", "/fetch/{Id}")
// ("order", "/order")
seriesToPoints := make(map[string][]v3.Point)
var keys []string
// seriesToAttrs is a mapping of key to a map of attribute key to attribute value
// for each series. This is used to populate the series' attributes
// For instance, for the above example, the seriesToAttrs will be
@ -4182,12 +4182,15 @@ func readRowsForTimeSeriesResult(rows driver.Rows, vars []interface{}, columnNam
groupBy, groupAttributes, metricPoint := readRow(vars, columnNames)
sort.Strings(groupBy)
key := strings.Join(groupBy, "")
if _, exists := seriesToAttrs[key]; !exists {
keys = append(keys, key)
}
seriesToAttrs[key] = groupAttributes
seriesToPoints[key] = append(seriesToPoints[key], metricPoint)
}
var seriesList []*v3.Series
for key := range seriesToPoints {
for _, key := range keys {
points := seriesToPoints[key]
// find the grouping sets point for the series