Fix stats: count kontaktiert via tag instead of status field

This commit is contained in:
Timo Uttenweiler
2026-03-27 17:15:09 +01:00
parent 11197c9db1
commit c232f0cb79

View File

@@ -3,12 +3,12 @@ import { prisma } from "@/lib/db";
export async function GET() { export async function GET() {
try { try {
const [total, newLeads, contacted, withEmail] = await Promise.all([ const [total, contacted, withEmail] = await Promise.all([
prisma.lead.count(), prisma.lead.count(),
prisma.lead.count({ where: { status: "new" } }), prisma.lead.count({ where: { tags: { contains: "kontaktiert" } } }),
prisma.lead.count({ where: { status: { in: ["contacted", "in_progress"] } } }),
prisma.lead.count({ where: { email: { not: null } } }), prisma.lead.count({ where: { email: { not: null } } }),
]); ]);
const newLeads = total - contacted;
// Daily counts for last 7 days // Daily counts for last 7 days
const sevenDaysAgo = new Date(); const sevenDaysAgo = new Date();