From 875f7ae0238b317aea89329f46e6e8950a504a8c Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:13:44 +0700 Subject: [PATCH] feat: stat by userType --- src/controllers/branch-controller.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index ea98c88..23841ef 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -1,4 +1,4 @@ -import { Prisma, Status } from "@prisma/client"; +import { Prisma, Status, UserType } from "@prisma/client"; import { Body, Controller, @@ -61,11 +61,12 @@ type BranchUpdate = { @Tags("Branch") @Security("keycloak") export class BranchController extends Controller { - @Get("stats") - async getStat() { + @Get("user-stats") + async getUserStat(@Query() userType?: UserType) { const list = await prisma.branchUser.groupBy({ - by: ["branchId"], _count: true, + where: { user: { userType } }, + by: "branchId", }); const record = await prisma.branch.findMany({