;
- ready: Ref;
};
const runningContainers = computed(() => containers.value.filter((container) => container.state === "running"));
@@ -64,10 +63,8 @@ type TotalStat = {
totalCPU: number;
totalMem: number;
};
-
const weightedStats: Record = {};
-
-watchOnce(hostContainers, (value) => {
+const initWeightedStats = () => {
for (const [host, containers] of Object.entries(hostContainers.value)) {
const mostRecent = ref({ totalCPU: 0, totalMem: 0 });
for (const container of containers) {
@@ -76,7 +73,10 @@ watchOnce(hostContainers, (value) => {
}
weightedStats[host] = reactive({ mostRecent, weighted: useExponentialMovingAverage(mostRecent) });
}
-});
+};
+
+watchOnce(hostContainers, initWeightedStats);
+initWeightedStats();
useIntervalFn(
() => {