From 916716b5891b062dc6e649e11c543f03b9eaa2f3 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 28 May 2023 21:10:21 -0700 Subject: [PATCH] properly calculate percent --- packages/client/src/widgets/server-metric/meilisearch.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/client/src/widgets/server-metric/meilisearch.vue b/packages/client/src/widgets/server-metric/meilisearch.vue index 4047793f5..80a3f4146 100644 --- a/packages/client/src/widgets/server-metric/meilisearch.vue +++ b/packages/client/src/widgets/server-metric/meilisearch.vue @@ -16,6 +16,7 @@ import { onBeforeUnmount, onMounted } from "vue"; import bytes from "@/filters/bytes"; import XPie from "./pie.vue"; import { i18n } from "@/i18n"; +import * as os from "@/os"; const props = defineProps<{ connection: any; @@ -23,7 +24,7 @@ const props = defineProps<{ }>(); let progress: number = $ref(0); - +let serverStats = $ref(null); let total_size: number = $ref(0); let index_count: number = $ref(0); let available: string = $ref("unavailable"); @@ -32,10 +33,13 @@ function onStats(stats) { total_size = stats.meilisearch.size; index_count = stats.meilisearch.indexed_count; available = stats.meilisearch.health; - progress = Math.floor((index_count / total_size) * 100); + progress = Math.floor((index_count / serverStats.notesCount) * 100); } onMounted(() => { + os.api("stats", {}).then((res) => { + serverStats = res; + }); props.connection.on("stats", onStats); });