Skip to content

Commit

Permalink
fix: check if stats available
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassimoen committed Jan 16, 2024
1 parent e0cbaed commit d8172c2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controllers/Statistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit d8172c2

Please sign in to comment.