From 2dfd7c2a041a50e81cafbd0c137847b5b22e8707 Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 8 Feb 2024 15:34:03 +0100 Subject: [PATCH] chore: checking if key data is longer than 0 --- backend/src/api/controllers/result.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/src/api/controllers/result.ts b/backend/src/api/controllers/result.ts index 3d25a2642..87e62a07b 100644 --- a/backend/src/api/controllers/result.ts +++ b/backend/src/api/controllers/result.ts @@ -245,7 +245,10 @@ export async function addResult( throw new MonkeyError(400, "Impossible funbox combination"); } - if (completedEvent.keySpacing !== "toolong") { + if ( + completedEvent.keySpacing !== "toolong" && + completedEvent.keySpacing.length > 0 + ) { completedEvent.keySpacingStats = { average: completedEvent.keySpacing.reduce( @@ -255,7 +258,10 @@ export async function addResult( }; } - if (completedEvent.keyDuration !== "toolong") { + if ( + completedEvent.keyDuration !== "toolong" && + completedEvent.keyDuration.length > 0 + ) { completedEvent.keyDurationStats = { average: completedEvent.keyDuration.reduce(