From 3f3d4d976a76bd61c5a1c4a37d96768b3fc789f0 Mon Sep 17 00:00:00 2001 From: mahyargdz Date: Sat, 31 May 2025 16:08:54 +0330 Subject: [PATCH] chore: add notification count to user get all notification --- src/modules/notifications/providers/notifications.service.ts | 4 +++- .../notifications/repositories/notifications.repository.ts | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/notifications/providers/notifications.service.ts b/src/modules/notifications/providers/notifications.service.ts index 22377f9..48a0a88 100755 --- a/src/modules/notifications/providers/notifications.service.ts +++ b/src/modules/notifications/providers/notifications.service.ts @@ -95,7 +95,9 @@ export class NotificationsService { //************************ */ async getAllNotifications(queryDto: SearchNotificationQueryDto, recipientId: string) { - return await this.notificationRepository.getAllNotifications(queryDto, recipientId); + const [notifications, count] = await this.notificationRepository.getAllNotifications(queryDto, recipientId); + const notificationCount = await this.countUserNotifications(recipientId); + return { notifications, notificationCount, count, paginate: true }; } //************************ */ diff --git a/src/modules/notifications/repositories/notifications.repository.ts b/src/modules/notifications/repositories/notifications.repository.ts index 1bb1ce6..fb08b6b 100755 --- a/src/modules/notifications/repositories/notifications.repository.ts +++ b/src/modules/notifications/repositories/notifications.repository.ts @@ -21,8 +21,6 @@ export class NotificationRepository extends Repository { queryBuilder.andWhere("notification.isRead = :isRead", { isRead: queryDto.isRead === 1 }); } - const [notifications, count] = await queryBuilder.orderBy("notification.createdAt", "DESC").skip(skip).take(limit).getManyAndCount(); - - return { notifications, count, paginate: true }; + return queryBuilder.orderBy("notification.createdAt", "DESC").skip(skip).take(limit).getManyAndCount(); } }