From d8172c259760290e2c49419d0996da0a8005c326 Mon Sep 17 00:00:00 2001 From: Jonas Simoen Date: Tue, 16 Jan 2024 22:37:19 +0100 Subject: [PATCH] fix: check if stats available --- src/controllers/Statistic.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controllers/Statistic.ts b/src/controllers/Statistic.ts index 674abea..937acc8 100644 --- a/src/controllers/Statistic.ts +++ b/src/controllers/Statistic.ts @@ -277,6 +277,9 @@ export const ImportMatchStatisticHandler = async (req: any, rep: any) => { if (res.status != 200 || !res.data || (Array.isArray(res.data.errors) && (res.data.errors.length > 0)) || Object.keys(res.data.errors).length !== 0) { throw new HttpError(Object.values(res.data.errors).reduce((s, v) => `${s}${v} `, '') as string, 429) } + if(res.data.response?.length === 0) { + throw new HttpError("No stats yet",404); + } const converted = res.data.response.map((resp: any) => { return resp.players.map((player: any) => { const stats = player.statistics[0]; @@ -315,6 +318,9 @@ export const ImportMatchStatisticHandler = async (req: any, rep: any) => { }); }); + console.log("converted 0", converted[0]); + console.log("converted 1", converted[1]); + const convertedToSingleTeam = converted[0].concat(converted[1]); const matchUpdate = await prisma.match.update({