feat: count customer by type
This commit is contained in:
parent
818dd044b6
commit
7cfc49eae0
1 changed files with 19 additions and 0 deletions
|
|
@ -52,6 +52,25 @@ function imageLocation(id: string) {
|
||||||
@Tags("Customer")
|
@Tags("Customer")
|
||||||
@Security("keycloak")
|
@Security("keycloak")
|
||||||
export class CustomerController extends Controller {
|
export class CustomerController extends Controller {
|
||||||
|
@Get("type-stats")
|
||||||
|
async stat() {
|
||||||
|
const list = await prisma.customer.groupBy({
|
||||||
|
by: "customerType",
|
||||||
|
_count: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return list.reduce<Record<CustomerType, number>>(
|
||||||
|
(a, c) => {
|
||||||
|
a[c.customerType] = c._count;
|
||||||
|
return a;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
CORP: 0,
|
||||||
|
PERS: 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
async list(
|
async list(
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue