fix(admin): filter duplicate daily puzzles in dashboard

This commit is contained in:
Hördle Bot
2025-11-23 00:01:06 +01:00
parent 291fc2037c
commit 77a769fb91

View File

@@ -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) { } catch (error) {
console.error('Error fetching daily puzzles:', error); console.error('Error fetching daily puzzles:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }); return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });