Fix sortSeries() function, fixes #1274

This commit is contained in:
Alexander Zobnin
2021-08-25 16:12:22 +03:00
parent 4b3d8e5106
commit 483e2aaa83
2 changed files with 14 additions and 3 deletions

View File

@@ -353,9 +353,8 @@ func applySortSeries(series []*timeseries.TimeSeriesData, params ...interface{})
return nil, errParsingFunctionParam(err)
}
aggFunc := timeseries.AggAvg
sorted := timeseries.SortBy(series, order, aggFunc)
return sorted, nil
timeseries.SortByName(series, order)
return series, nil
}
func applyTimeShiftPre(query *QueryModel, items []*zabbix.Item, params ...interface{}) error {

View File

@@ -50,3 +50,15 @@ func SortByItem(series []*TimeSeriesData) []*TimeSeriesData {
return series
}
func SortByName(series []*TimeSeriesData, order string) []*TimeSeriesData {
sort.Slice(series, func(i, j int) bool {
if order == "desc" {
return series[i].Meta.Name > series[j].Meta.Name
} else {
return series[i].Meta.Name < series[j].Meta.Name
}
})
return series
}