panhui 2 vuotta sitten
vanhempi
commit
cc6d11069f
2 muutettua tiedostoa jossa 12 lisäystä ja 8 poistoa
  1. 4 4
      src/chat/chat.controller.ts
  2. 8 4
      src/users/users.admin.controller.ts

+ 4 - 4
src/chat/chat.controller.ts

@@ -56,10 +56,10 @@ export class ChatController {
 
     @Get('/getDatas')
     public async getDatas(@Query() { apiUserId }) {
-        const apiNum = await this.chatService.getCount(Number(apiUserId), Role.Api)
-        const userNum = await this.chatService.getCount(Number(apiUserId), Role.User)
-        const todayNum = await this.chatService.getCount(Number(apiUserId), undefined, format(new Date(), 'yyyy-MM-dd'))
-        const week = await this.chatService.getWeekCount(Number(apiUserId))
+        const apiNum = await this.chatService.getCount(apiUserId?Number(apiUserId):undefined, Role.Api)
+        const userNum = await this.chatService.getCount(apiUserId?Number(apiUserId):undefined, Role.User)
+        const todayNum = await this.chatService.getCount(apiUserId?Number(apiUserId):undefined, undefined, format(new Date(), 'yyyy-MM-dd'))
+        const week = await this.chatService.getWeekCount(apiUserId?Number(apiUserId):undefined)
         return {
             api: apiNum,
             user: userNum,

+ 8 - 4
src/users/users.admin.controller.ts

@@ -73,10 +73,14 @@ export class UsersAdminController {
 
     @Get('/getDatas')
     public async getDatas(@Query() { apiUserId }) {
-        const apiNum = await this.usersService.getCount(Number(apiUserId), Role.Api)
-        const userNum = await this.usersService.getCount(Number(apiUserId), Role.User)
-        const todayNum = await this.usersService.getCount(Number(apiUserId), undefined, format(new Date(), 'yyyy-MM-dd'))
-        const week = await this.usersService.getWeekCount(Number(apiUserId))
+        const apiNum = await this.usersService.getCount(apiUserId ? Number(apiUserId) : undefined, Role.Api)
+        const userNum = await this.usersService.getCount(apiUserId ? Number(apiUserId) : undefined, Role.User)
+        const todayNum = await this.usersService.getCount(
+            apiUserId ? Number(apiUserId) : undefined,
+            undefined,
+            format(new Date(), 'yyyy-MM-dd')
+        )
+        const week = await this.usersService.getWeekCount(apiUserId ? Number(apiUserId) : undefined)
         return {
             api: apiNum,
             user: userNum,