Skip to content

Commit d2804a3

Browse files
authored
Merge pull request #471 from waiterZen/sliping-away
[sliping-away] correct percentage
2 parents 3edfdf2 + 24ac024 commit d2804a3

File tree

1 file changed

+8
-7
lines changed
  • plugins/slipping-away-users/api

1 file changed

+8
-7
lines changed

plugins/slipping-away-users/api/api.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,14 @@ const plugin = {},
4646
BPromise.all(tasks).spread(function() {
4747
const result = [];
4848
periods.forEach((p,index) => {
49-
const percentage = (arguments[index] / arguments[periods.length]) * 100;
50-
result.push({
51-
period: p,
52-
count: arguments[index],
53-
percentage: `${ percentage.toFixed(2) }`,
54-
timeStamp: timeList[p],
55-
})
49+
let percentage = (arguments[index] / arguments[periods.length]) * 100;
50+
percentage = isNaN(percentage) ? 0 : percentage;
51+
result.push({
52+
period: p,
53+
count: arguments[index],
54+
percentage: `${ percentage.toFixed(2) }`,
55+
timeStamp: timeList[p],
56+
})
5657
});
5758
common.returnOutput(params, result);
5859
});

0 commit comments

Comments
 (0)