feat: count employee by gender

This commit is contained in:
Methapon2001 2024-06-12 15:52:57 +07:00
parent 0bca85d460
commit fc2d06ad5d

View file

@ -209,6 +209,22 @@ export class EmployeeController extends Controller {
});
}
@Get("stats/gender")
async getEmployeeStatsGender(@Query() customerBranchId?: string) {
return await prisma.employee
.groupBy({
_count: true,
by: ["gender"],
where: { customerBranchId },
})
.then((res) =>
res.reduce<Record<string, number>>((a, c) => {
a[c.gender] = c._count;
return a;
}, {}),
);
}
@Get()
async list(
@Query() zipCode?: string,