diff --git a/app/api/leads/route.ts b/app/api/leads/route.ts index 43388c5..d0bc570 100644 --- a/app/api/leads/route.ts +++ b/app/api/leads/route.ts @@ -79,7 +79,7 @@ export async function GET(req: NextRequest) { }; 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.findMany({ where, @@ -87,8 +87,11 @@ export async function GET(req: NextRequest) { skip: (page - 1) * perPage, take: perPage, }), + prisma.lead.count(), ]); + console.log(`[leads API] rawCount=${rawCount} total=${total} leads=${leads.length} where=${JSON.stringify(where)}`); + return NextResponse.json({ leads, total,