chore: add notification count to user get all notification
This commit is contained in:
@@ -95,7 +95,9 @@ export class NotificationsService {
|
|||||||
//************************ */
|
//************************ */
|
||||||
|
|
||||||
async getAllNotifications(queryDto: SearchNotificationQueryDto, recipientId: string) {
|
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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************ */
|
//************************ */
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ export class NotificationRepository extends Repository<Notification> {
|
|||||||
queryBuilder.andWhere("notification.isRead = :isRead", { isRead: queryDto.isRead === 1 });
|
queryBuilder.andWhere("notification.isRead = :isRead", { isRead: queryDto.isRead === 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const [notifications, count] = await queryBuilder.orderBy("notification.createdAt", "DESC").skip(skip).take(limit).getManyAndCount();
|
return queryBuilder.orderBy("notification.createdAt", "DESC").skip(skip).take(limit).getManyAndCount();
|
||||||
|
|
||||||
return { notifications, count, paginate: true };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user