fix: pagination and ordering to getNotifications (#1016) - #1404
Open
Sagethepeak wants to merge 3 commits into
Open
fix: pagination and ordering to getNotifications (#1016)#1404Sagethepeak wants to merge 3 commits into
Sagethepeak wants to merge 3 commits into
Conversation
…inafcode#1016) - paginate getNotifications with PaginationQueryDto (skip/take), order {createdAt: DESC} newest-first and standard paginated envelope - add optional status/isRead filter using indexed where clauses (avoids full scan) - update PaginationService.paginate to support DESC/ASC ordering and correct cursor operator (< vs >) - delegate findForUser to getNotifications for single source of truth - add composite indexes on notification(userId, createdAt DESC), (userId, isRead, createdAt), (userId, status, createdAt) - add migration 1810000000000-add-notifications-pagination-indexes.ts - expose pagination query params via NotificationsController with ApiQuery decorators Closes rinafcode#1016
…d/status filters Global ValidationPipe whitelist+forbidNonWhitelisted would reject isRead/status when controller used PaginationQueryDto intersection type. Introduce NotificationsQueryDto extends PaginationQueryDto with @Transform for string boolean coercion and @IsEnum for status. Ensures GET /notifications?isRead=false&status=sent passes validation and uses indexes.
|
@Sagethepeak Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Well done on the job done so far! |
- merge duplicate @nestjs/swagger import in notifications.controller.ts - fix prettier whitespace in notifications.service.ts offset line
Author
Sorry for the delay, there was error with "run lint". Fixed that already. |
Contributor
|
Thee still lint errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #1016 —
NotificationsService.getNotificationswas unbounded and unordered.Changes
PaginationQueryDtosupport withorder: { createdAt: 'DESC' },skip/takereturning standard paginated envelope viaPaginationService.paginatestatus/isReadfilter using indexedandWhere(avoids full scan)PaginationService.paginateto supportDESC(newest-first) with correct cursor operator<vs>NotificationsQueryDto extends PaginationQueryDtofor validated query paramsnotification(userId, createdAt DESC),(userId, isRead, createdAt),(userId, status, createdAt)1810000000000-add-notifications-pagination-indexes.tsVerification
tsc --noEmit --skipLibCheckpass (no errors for edited files)jest src/notifications/notifications.service.spec.tsPASSCloses #1016