|
@@ -14,6 +14,7 @@
|
|
|
let mergedDocuments = [];
|
|
|
|
|
|
function calculatePercentage(distance: number) {
|
|
|
+ if (typeof distance !== 'number') return null;
|
|
|
if (distance < 0) return 0;
|
|
|
if (distance > 1) return 100;
|
|
|
return Math.round(distance * 10000) / 100;
|
|
@@ -122,11 +123,14 @@
|
|
|
<div class="text-sm my-1 dark:text-gray-400 flex items-center gap-2 w-fit">
|
|
|
{#if showPercentage}
|
|
|
{@const percentage = calculatePercentage(document.distance)}
|
|
|
- <span
|
|
|
- class={`px-1 rounded-sm font-medium ${getRelevanceColor(percentage)}`}
|
|
|
- >
|
|
|
- {percentage.toFixed(2)}%
|
|
|
- </span>
|
|
|
+
|
|
|
+ {#if typeof percentage === 'number'}
|
|
|
+ <span
|
|
|
+ class={`px-1 rounded-sm font-medium ${getRelevanceColor(percentage)}`}
|
|
|
+ >
|
|
|
+ {percentage.toFixed(2)}%
|
|
|
+ </span>
|
|
|
+ {/if}
|
|
|
<span class="text-gray-500 dark:text-gray-500">
|
|
|
({(document?.distance ?? 0).toFixed(4)})
|
|
|
</span>
|