From a559c6799d5a7b844b8f11a300d8a51d8322f0fc Mon Sep 17 00:00:00 2001 From: Spythere Date: Wed, 15 Sep 2021 22:52:58 +0200 Subject: [PATCH] =?UTF-8?q?Hotfix:=20=C5=9Brednia=20d=C5=82ugo=C5=9B=C4=87?= =?UTF-8?q?=20rozk=C5=82ad=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TrainsView/TrainStats.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/TrainsView/TrainStats.vue b/src/components/TrainsView/TrainStats.vue index e4bd90c..c0fe283 100644 --- a/src/components/TrainsView/TrainStats.vue +++ b/src/components/TrainsView/TrainStats.vue @@ -138,12 +138,16 @@ export default defineComponent({ const timetableStats = computed(() => { if (props.trains.length == 0) return { avg: "0", min: "0", max: "0" }; + const activeTrainsLength = props.trains.filter( + (train) => train.timetableData + ).length; + const avg = ( props.trains.reduce( (acc, train) => train.timetableData ? acc + train.timetableData.routeDistance : acc, 0 - ) / props.trains.length + ) / activeTrainsLength ).toFixed(2); const minMaxDistance = props.trains.reduce((acc, train) => {