Overview
NotificationsService.getNotifications(userId) executes this.notificationRepository.find({ where: { userId } }) — every notification ever created for that user, in unspecified order. Notifications are high-volume by nature and are never deleted by any code path in the module, so this grows without bound for active users. The absence of an order clause also means the result ordering is whatever the storage engine returns, so a client cannot rely on newest-first even before considering the volume.
Specifications
Features:
- Notification retrieval is paginated and ordered newest-first.
- Unread filtering is supported without a full scan.
Tasks:
- Add
PaginationQueryDto support with order: { createdAt: 'DESC' }, skip, and take, returning the standard paginated envelope.
- Add an optional
status / unread filter parameter.
- Add a composite index on
notification(userId, createdAt DESC).
- Coordinate with the retention policy so old notifications are pruned rather than accumulating indefinitely.
Impacted Files:
src/notifications/notifications.service.ts
src/notifications/entities/notification.entity.ts
Acceptance Criteria
- Notification listing returns a bounded page ordered newest-first.
- Unread filtering uses an index rather than scanning.
- The composite index exists via migration.
Overview
NotificationsService.getNotifications(userId)executesthis.notificationRepository.find({ where: { userId } })— every notification ever created for that user, in unspecified order. Notifications are high-volume by nature and are never deleted by any code path in the module, so this grows without bound for active users. The absence of anorderclause also means the result ordering is whatever the storage engine returns, so a client cannot rely on newest-first even before considering the volume.Specifications
Features:
Tasks:
PaginationQueryDtosupport withorder: { createdAt: 'DESC' },skip, andtake, returning the standard paginated envelope.status/ unread filter parameter.notification(userId, createdAt DESC).Impacted Files:
src/notifications/notifications.service.tssrc/notifications/entities/notification.entity.tsAcceptance Criteria