From c232f0cb79a115e7a177756adf429a1832647a26 Mon Sep 17 00:00:00 2001 From: Timo Uttenweiler Date: Fri, 27 Mar 2026 17:15:09 +0100 Subject: [PATCH] Fix stats: count kontaktiert via tag instead of status field --- app/api/leads/stats/route.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/leads/stats/route.ts b/app/api/leads/stats/route.ts index 33e43ae..00d9fbf 100644 --- a/app/api/leads/stats/route.ts +++ b/app/api/leads/stats/route.ts @@ -3,12 +3,12 @@ import { prisma } from "@/lib/db"; export async function GET() { try { - const [total, newLeads, contacted, withEmail] = await Promise.all([ + const [total, contacted, withEmail] = await Promise.all([ prisma.lead.count(), - prisma.lead.count({ where: { status: "new" } }), - prisma.lead.count({ where: { status: { in: ["contacted", "in_progress"] } } }), + prisma.lead.count({ where: { tags: { contains: "kontaktiert" } } }), prisma.lead.count({ where: { email: { not: null } } }), ]); + const newLeads = total - contacted; // Daily counts for last 7 days const sevenDaysAgo = new Date();