From 965f79f31adcaa3900c93f282d12c9ff86a3020a Mon Sep 17 00:00:00 2001 From: headlessdev Date: Sat, 19 Apr 2025 00:00:10 +0200 Subject: [PATCH] Refactor server count retrieval in POST request to differentiate between servers with and without VMs --- app/api/dashboard/get/route.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/api/dashboard/get/route.ts b/app/api/dashboard/get/route.ts index c35c557..c8d6949 100644 --- a/app/api/dashboard/get/route.ts +++ b/app/api/dashboard/get/route.ts @@ -3,7 +3,19 @@ import { prisma } from "@/lib/prisma"; export async function POST(request: NextRequest) { try { - const serverCount = await prisma.server.count(); + const serverCountNoVMs = await prisma.server.count({ + where: { + hostServer: 0 + } + }); + + const serverCountOnlyVMs = await prisma.server.count({ + where: { + hostServer: { + not: 0 + } + } + }); const applicationCount = await prisma.application.count(); @@ -12,7 +24,8 @@ export async function POST(request: NextRequest) { }); return NextResponse.json({ - serverCount, + serverCountNoVMs, + serverCountOnlyVMs, applicationCount, onlineApplicationsCount });