From 77a769fb917b7033c665c6a1bcf97dadce7fb45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sun, 23 Nov 2025 00:01:06 +0100 Subject: [PATCH] fix(admin): filter duplicate daily puzzles in dashboard --- app/api/admin/daily-puzzles/route.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/admin/daily-puzzles/route.ts b/app/api/admin/daily-puzzles/route.ts index 3985071..231d40c 100644 --- a/app/api/admin/daily-puzzles/route.ts +++ b/app/api/admin/daily-puzzles/route.ts @@ -42,7 +42,20 @@ export async function GET() { } })); - return NextResponse.json(formattedPuzzles); + // Filter out duplicates (keep only the first one per category) + // This matches the behavior of getOrCreateDailyPuzzle which uses findFirst + const uniquePuzzles = []; + const seenCategories = new Set(); + + for (const puzzle of formattedPuzzles) { + const key = `${puzzle.categoryType}-${puzzle.genreId || 'null'}-${puzzle.specialId || 'null'}`; + if (!seenCategories.has(key)) { + seenCategories.add(key); + uniquePuzzles.push(puzzle); + } + } + + return NextResponse.json(uniquePuzzles); } catch (error) { console.error('Error fetching daily puzzles:', error); return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });