From 102220c9345dc4989c309c4b5f25ef13d8692f6b Mon Sep 17 00:00:00 2001 From: Domingo Dirutigliano Date: Sun, 3 Nov 2024 19:51:14 +0100 Subject: [PATCH] flag/attack chart start from first != 0 value (there was some situations it was not) --- backend/models/config.py | 3 +-- frontend/src/components/charts/LineChartAttackView.tsx | 4 ++-- frontend/src/components/charts/LineChartFlagView.tsx | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/models/config.py b/backend/models/config.py index 12cee59..c7f9d50 100644 --- a/backend/models/config.py +++ b/backend/models/config.py @@ -1,6 +1,5 @@ -from pydantic import BaseModel, AwareDatetime -from pydantic import BaseModel, model_validator +from pydantic import BaseModel, AwareDatetime, model_validator from typing_extensions import Self from functools import cache from pydantic import NonNegativeInt, PositiveInt diff --git a/frontend/src/components/charts/LineChartAttackView.tsx b/frontend/src/components/charts/LineChartAttackView.tsx index d9b9d38..ce0ef5d 100644 --- a/frontend/src/components/charts/LineChartAttackView.tsx +++ b/frontend/src/components/charts/LineChartAttackView.tsx @@ -70,7 +70,7 @@ export const LineChartAttackView = ({ seriesType, attackType, chartType, withCon const service_id = exploits.data?.find((exploit) => exploit.id == id)?.service if (service_id == null) return const oldValue = (!result[service_id] || typeof result[service_id] == "string")?0:result[service_id] as number - if (tick.exploits[id]?.attacks[finalAttackStatus] == null && initialSkip) return service_id + if ((tick.exploits[id]?.attacks[finalAttackStatus]??0) == 0 && initialSkip) return service_id initialSkip = false result[service_id] = tick.exploits[id]?.attacks[finalAttackStatus]??0 + oldValue return service_id @@ -82,7 +82,7 @@ export const LineChartAttackView = ({ seriesType, attackType, chartType, withCon } } else { const ids_used = Object.keys(tick[finalSeries]).map((id) => { - if (tick[finalSeries][id]?.attacks[finalAttackStatus] == null && initialSkip) return id + if ((tick[finalSeries][id]?.attacks[finalAttackStatus]??0) == 0 && initialSkip) return id initialSkip = false result[id] = tick[finalSeries][id]?.attacks[finalAttackStatus]??0 return id diff --git a/frontend/src/components/charts/LineChartFlagView.tsx b/frontend/src/components/charts/LineChartFlagView.tsx index e824d2c..b404d93 100644 --- a/frontend/src/components/charts/LineChartFlagView.tsx +++ b/frontend/src/components/charts/LineChartFlagView.tsx @@ -70,7 +70,7 @@ export const LineChartFlagView = ({ seriesType, flagType, chartType, withControl const service_id = exploits.data?.find((exploit) => exploit.id == id)?.service if (service_id == null) return const oldValue = (!result[service_id] || typeof result[service_id] == "string")?0:result[service_id] as number - if (tick.exploits[id]?.flags[finalFlagStatus] == null && initialSkip) return service_id + if ((tick.exploits[id]?.flags[finalFlagStatus]??0) == 0 && initialSkip) return service_id initialSkip = false result[service_id] = tick.exploits[id]?.flags[finalFlagStatus]??0 + oldValue return service_id @@ -82,7 +82,7 @@ export const LineChartFlagView = ({ seriesType, flagType, chartType, withControl } }else{ const used_ids = Object.keys(tick[finalSeries]).map((id) => { - if (tick[finalSeries][id]?.flags[finalFlagStatus] == null && initialSkip) return id + if ((tick[finalSeries][id]?.flags[finalFlagStatus]??0) == 0 && initialSkip) return id initialSkip = false result[id] = tick[finalSeries][id]?.flags[finalFlagStatus]??0 return id