Refactor server count retrieval in POST request to differentiate between servers with and without VMs

This commit is contained in:
headlessdev 2025-04-19 00:00:10 +02:00
parent f1c0cc9deb
commit 965f79f31a

View File

@ -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
});