Sort trend data, fixes #202

This commit is contained in:
Alexander Zobnin
2017-06-15 22:31:00 +03:00
parent 8f7c0701b1
commit 7d97dfbef9
8 changed files with 50 additions and 8 deletions

View File

@@ -14,3 +14,7 @@ export const SEV_DISASTER = 5;
export const SHOW_ALL_TRIGGERS = [0, 1];
export const SHOW_ALL_EVENTS = [0, 1];
export const SHOW_OK_EVENTS = 1;
// Data point
export const DATAPOINT_VALUE = 0;
export const DATAPOINT_TS = 1;

View File

@@ -147,15 +147,23 @@ class ZabbixAPIDatasource {
if (useTrends) {
let valueType = this.getTrendValueType(target);
getHistoryPromise = this.zabbix.getTrend(items, timeFrom, timeTo)
.then(history => {
return responseHandler.handleTrends(history, items, valueType);
.then(history => {
return responseHandler.handleTrends(history, items, valueType);
})
.then(timeseries => {
// Sort trend data, issue #202
_.forEach(timeseries, series => {
series.datapoints = _.sortBy(series.datapoints, point => point[c.DATAPOINT_TS]);
});
return timeseries;
});
} else {
// Use history
getHistoryPromise = this.zabbix.getHistory(items, timeFrom, timeTo)
.then(history => {
return responseHandler.handleHistory(history, items);
});
.then(history => {
return responseHandler.handleHistory(history, items);
});
}
return getHistoryPromise.then(timeseries_data => {