Skip to content

Commit

Permalink
ignore games with error from lichess
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Mar 15, 2024
1 parent 157dd91 commit 9886bc5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/lichess/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ type PositionGames = {
export async function convertToNormalized(
data: PositionGames,
): Promise<NormalizedGame[]> {
return await Promise.all(
const results = await Promise.allSettled(
data.map(async (game, i) => {
const pgn = await getLichessGame(game.id);
const { headers, root } = await parsePGN(pgn);
Expand All @@ -183,6 +183,9 @@ export async function convertToNormalized(
return normalized;
}),
);
return results
.filter((r) => r.status === "fulfilled")
.map((r) => (r as PromiseFulfilledResult<NormalizedGame>).value);
}

type PositionData = {
Expand Down

0 comments on commit 9886bc5

Please sign in to comment.