From d676c5339f386d88a5a204765b0e9974ab83b600 Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 24 Oct 2024 10:40:33 +0300 Subject: [PATCH] bugfix health monitor --- client/src/stores/healthcheck.store.ts | 9 ++--- .../views/HealthCheck/HealthDay.service.ts | 6 +-- .../views/HealthCheck/HealthTargetView.vue | 37 +++++++++++-------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/client/src/stores/healthcheck.store.ts b/client/src/stores/healthcheck.store.ts index 5b30274..9f61c12 100644 --- a/client/src/stores/healthcheck.store.ts +++ b/client/src/stores/healthcheck.store.ts @@ -16,7 +16,7 @@ export interface HealthDay extends BaseEntity { health_target_id: number } -export interface HealthUnit extends BaseEntity { +export interface HealthUnit { request_datetime: number status: boolean response_time: number @@ -65,9 +65,6 @@ export const useHealthCheckStore = defineStore({ this.loadDays(this.targets), ] ) - this.targets.forEach( - t => this.loadUnits(t).then() - ) } this.loadings.targets = false }, @@ -91,7 +88,7 @@ export const useHealthCheckStore = defineStore({ el => { hDays.push( { - request_datetime: el[2], + request_datetime: el[2] * 1000, status: el[1], response_time: el[0], } @@ -99,7 +96,7 @@ export const useHealthCheckStore = defineStore({ } ) this.units.set(healthTarget.id, hDays) - + return hDays } } } diff --git a/client/src/views/HealthCheck/HealthDay.service.ts b/client/src/views/HealthCheck/HealthDay.service.ts index f34fb83..f163b44 100644 --- a/client/src/views/HealthCheck/HealthDay.service.ts +++ b/client/src/views/HealthCheck/HealthDay.service.ts @@ -2,7 +2,7 @@ import {HealthDay, HealthTarget, useHealthCheckStore} from "../../stores/healthc import {equalDate} from "../Utils.ts"; export class HealthDayService { - private healthDay: HealthDay | undefined + private readonly healthDay: HealthDay | undefined constructor(healthDay: HealthDay | undefined) { this.healthDay = healthDay @@ -50,8 +50,8 @@ export class HealthDayService { if (this.healthDay == undefined) return const fallTimes = this.getFallTimes() const lostTimes = this.getLostTimes() - if (!fallTimes) return undefined - return (fallTimes / this.healthDay.count_response_time) * 100 + (lostTimes / (60 * 24)) * 30 + if (fallTimes == undefined) return undefined + return (fallTimes / (60 * 24)) * 100 + (lostTimes / (60 * 24)) * 30 } getFallTimes() { diff --git a/client/src/views/HealthCheck/HealthTargetView.vue b/client/src/views/HealthCheck/HealthTargetView.vue index 3674838..47bdd46 100644 --- a/client/src/views/HealthCheck/HealthTargetView.vue +++ b/client/src/views/HealthCheck/HealthTargetView.vue @@ -1,6 +1,6 @@ @@ -104,16 +111,14 @@ export default defineComponent({
-
- - - + + + - {{ healthTarget.title }} - - - -
+ {{ healthTarget.title }} + + +
@@ -130,7 +135,7 @@ export default defineComponent({

Response Times:

-
+