diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index 49edaa3..a1463cc 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -61,6 +61,22 @@ type BranchUpdate = { @Tags("Branch") @Security("keycloak") export class BranchController extends Controller { + @Get("stats") + async getStats() { + const list = await prisma.branch.groupBy({ + _count: true, + by: "isHeadOffice", + }); + + return list.reduce>( + (a, c) => { + a[c.isHeadOffice ? "hq" : "br"] = c._count; + return a; + }, + { hq: 0, br: 0 }, + ); + } + @Get("user-stats") async getUserStat(@Query() userType?: UserType) { const list = await prisma.branchUser.groupBy({