jkabot
09/19/2018, 8:40 PMfunction percentComplete(stage: StageStatus) {
// both total and pending are 0 when stage has not happened
if (stage.total === 0) {
return 0;
}
if (stage.pending === 0) {
return 100;
}
const pct = 100 * (stage.total - stage.pending) / stage.total;
// round to two decimal places
return Math.floor(100 * pct) / 100;
}