Add debug logging to leads API

This commit is contained in:
Timo Uttenweiler
2026-04-09 11:45:04 +02:00
parent 2c9afe76cf
commit 85cc6efc19

View File

@@ -79,7 +79,7 @@ export async function GET(req: NextRequest) {
}; };
const orderByField = validSortFields[sortBy] ? sortBy : "capturedAt"; const orderByField = validSortFields[sortBy] ? sortBy : "capturedAt";
const [total, leads] = await Promise.all([ const [total, leads, rawCount] = await Promise.all([
prisma.lead.count({ where }), prisma.lead.count({ where }),
prisma.lead.findMany({ prisma.lead.findMany({
where, where,
@@ -87,8 +87,11 @@ export async function GET(req: NextRequest) {
skip: (page - 1) * perPage, skip: (page - 1) * perPage,
take: perPage, take: perPage,
}), }),
prisma.lead.count(),
]); ]);
console.log(`[leads API] rawCount=${rawCount} total=${total} leads=${leads.length} where=${JSON.stringify(where)}`);
return NextResponse.json({ return NextResponse.json({
leads, leads,
total, total,