From 3f5f955d9d33065b670de508b5b36a15c1a5b0ec Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 28 Jan 2024 10:44:51 -0500 Subject: [PATCH 1/2] fix(common): calculate percentage to tenth decimal place Signed-off-by: Adam Setch --- src/shared/common.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/shared/common.js b/src/shared/common.js index a6a29b08c..53512e13a 100644 --- a/src/shared/common.js +++ b/src/shared/common.js @@ -410,17 +410,17 @@ $common.valueWithDefault = function valueWithDefault(variable, defaultValue) { * function will return a percentage rounded to the tenth decimal place. */ $common.calcProgressPercent = function calcProgressPercent(total, completed) { - if (total > 0) { + if (completed > total) { + // In something has already been completed (e.g. suppressed) and the completed value + // is greater than the total, return 100% + return 100; + } else if (total > 0) { if (completed === 0) { return 0; } else { let percentage = (completed / total) * 100; - return Math.round(percentage); + return Math.round(percentage * 10) / 10; } - } else if (completed > total) { - // In something has already been completed (e.g. suppressed) and the completed value - // is greater than the total, return 100% - return 100; } return 0; // the absence of work does not imply progress. }; From e6555f438902cc2bca13adbf810ce657f02c18ae Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 28 Jan 2024 10:49:13 -0500 Subject: [PATCH 2/2] fix(common): return 100 if greater than or equal to Signed-off-by: Adam Setch --- src/shared/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/common.js b/src/shared/common.js index 53512e13a..2f98633f3 100644 --- a/src/shared/common.js +++ b/src/shared/common.js @@ -410,7 +410,7 @@ $common.valueWithDefault = function valueWithDefault(variable, defaultValue) { * function will return a percentage rounded to the tenth decimal place. */ $common.calcProgressPercent = function calcProgressPercent(total, completed) { - if (completed > total) { + if (completed >= total) { // In something has already been completed (e.g. suppressed) and the completed value // is greater than the total, return 100% return 100;