2026-04-10 21:41:49 +02:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
import { prisma } from "../../../../lib/prisma";
|
|
|
|
|
|
|
|
|
|
export async function GET() {
|
|
|
|
|
const date = new Date().toISOString().slice(0, 10);
|
|
|
|
|
const puzzle = await prisma.dailyPuzzle.findUnique({ where: { date } });
|
|
|
|
|
if (!puzzle) return NextResponse.json([]);
|
|
|
|
|
|
|
|
|
|
const results = await prisma.dailyResult.findMany({
|
|
|
|
|
where: { puzzleId: puzzle.id, won: true },
|
|
|
|
|
include: { user: { select: { name: true } } },
|
|
|
|
|
orderBy: [{ clicks: "asc" }, { timeSeconds: "asc" }],
|
|
|
|
|
take: 20,
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-11 15:20:29 +02:00
|
|
|
return NextResponse.json(
|
|
|
|
|
results.map((r, i) => ({
|
|
|
|
|
rank: i + 1,
|
|
|
|
|
name: r.user.name,
|
|
|
|
|
clicks: r.clicks,
|
|
|
|
|
timeSeconds: r.timeSeconds,
|
|
|
|
|
userId: r.userId,
|
|
|
|
|
})),
|
|
|
|
|
);
|
2026-04-10 21:41:49 +02:00
|
|
|
}
|