Add division by zero guards in traceList computed and conformance rate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 18:04:51 +08:00
parent d3bba9d1a2
commit b6499020c6

View File

@@ -165,6 +165,7 @@ const traceList = computed(() => {
const sum = props.listTraces const sum = props.listTraces
.map((trace) => trace.count) .map((trace) => trace.count)
.reduce((acc, cur) => acc + cur, 0); .reduce((acc, cur) => acc + cur, 0);
if (sum === 0) return [];
return props.listTraces return props.listTraces
.map((trace) => { .map((trace) => {
@@ -274,7 +275,7 @@ watch(infinite404, (newValue) => {
* @returns {string} The formatted percentage string. * @returns {string} The formatted percentage string.
*/ */
function getPercentLabel(val) { function getPercentLabel(val) {
if ((val * 100).toFixed(1) >= 100) return 100; if (Number((val * 100).toFixed(1)) >= 100) return 100;
else return parseFloat((val * 100).toFixed(1)); else return parseFloat((val * 100).toFixed(1));
} }
/** /**