feat: stats user by user type
This commit is contained in:
parent
1f96418de0
commit
1e06b3356f
1 changed files with 21 additions and 0 deletions
|
|
@ -104,6 +104,27 @@ function imageLocation(id: string) {
|
|||
@Tags("User")
|
||||
@Security("keycloak")
|
||||
export class UserController extends Controller {
|
||||
@Get("type-stats")
|
||||
async getUserTypeStats() {
|
||||
const list = await prisma.user.groupBy({
|
||||
by: "userType",
|
||||
_count: true,
|
||||
});
|
||||
|
||||
return list.reduce<Record<UserType, number>>(
|
||||
(a, c) => {
|
||||
a[c.userType] = c._count;
|
||||
return a;
|
||||
},
|
||||
{
|
||||
USER: 0,
|
||||
MESSENGER: 0,
|
||||
DELEGATE: 0,
|
||||
AGENCY: 0,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@Get()
|
||||
async getUser(
|
||||
@Query() userType?: UserType,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue