Skip to content

Commit

Permalink
honour round option when averaging (#286)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric <[email protected]>
  • Loading branch information
tuxyme and Eric authored Oct 24, 2023
1 parent 0a17190 commit dfdba0f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ function finishAggregation(options) {
}
options.result = finalResult;
} else if (options.aggregate === 'average') {
const round = options.round || 100;
let startIndex = 0;
let endIndex = options.result.length;
const finalResult = [];
Expand All @@ -425,7 +426,7 @@ function finishAggregation(options) {
if (options.result[k] !== undefined && options.result[k].val.ts) {
finalResult.push({
ts: options.result[k].val.ts,
val: options.result[k].val.val !== null ? Math.round(options.result[k].val.val / options.averageCount[k] * 100) / 100 : null
val: options.result[k].val.val !== null ? Math.round(options.result[k].val.val / options.averageCount[k] * round) / round : null
});
} else {
// no one value in this interval
Expand Down

0 comments on commit dfdba0f

Please sign in to comment.