Fix to consolidate avg accuracy (#753)
* The interval must fit exactly n times to the time range and query made so that the resulting avg will be exact * Add interval fix also to trend query
This commit is contained in:
@@ -43,6 +43,12 @@ export class SQLConnector extends DBConnector {
|
||||
let {intervalMs, consolidateBy} = options;
|
||||
let intervalSec = Math.ceil(intervalMs / 1000);
|
||||
|
||||
// The interval must match the time range exactly n times, otherwise
|
||||
// the resulting first and last data points will yield invalid values in the
|
||||
// calculated average value in downsampleSeries - when using consolidateBy(avg)
|
||||
let numOfIntervals = Math.ceil((timeTill - timeFrom) / intervalSec);
|
||||
intervalSec = (timeTill - timeFrom) / numOfIntervals;
|
||||
|
||||
consolidateBy = consolidateBy || 'avg';
|
||||
let aggFunction = dbConnector.consolidateByFunc[consolidateBy];
|
||||
|
||||
@@ -66,6 +72,12 @@ export class SQLConnector extends DBConnector {
|
||||
let { intervalMs, consolidateBy } = options;
|
||||
let intervalSec = Math.ceil(intervalMs / 1000);
|
||||
|
||||
// The interval must match the time range exactly n times, otherwise
|
||||
// the resulting first and last data points will yield invalid values in the
|
||||
// calculated average value in downsampleSeries - when using consolidateBy(avg)
|
||||
let numOfIntervals = Math.ceil((timeTill - timeFrom) / intervalSec);
|
||||
intervalSec = (timeTill - timeFrom) / numOfIntervals;
|
||||
|
||||
consolidateBy = consolidateBy || 'avg';
|
||||
let aggFunction = dbConnector.consolidateByFunc[consolidateBy];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user