fix(notifications): exclude soft-deleted rows from counts and mutations (closes #1606) - #1798
Open
rudrasatani13 wants to merge 1 commit into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Closes #1606.
What was wrong
TypeORM applies the
@DeleteDateColumnfilter only to select queries - it lives inQueryBuilder.createWhereExpression()behindqueryType === "select"(checked in the installed typeorm 0.3.28). Sofind*andcount()already skip deleted rows, but everyupdate(criteria, patch)innotifications.service.tsdid not:markAsRead(id)returned success for a soft-deleted notification and mutated it.markAllAsUnread/markMultipleAsUnreadflipped soft-deleted rows back toread = false- invisible rows that keep that state, and get picked up by any consumer that does not use a TypeORM select (raw SQL, aggregations,withDeletedreads).markAllAsRead/markMultipleAsReadkept touching rows the user had deleted.What changed
activeNotificationWhere(userAddress, extra)- one private helper that addsdeleted_at: IsNull()to any criteria.findAllForUser(page query and its unread count),getUnreadCount,markAsRead,markAllAsRead,markMultipleAsRead,markAllAsUnread,markMultipleAsUnread.Tests
notifications.service.spec.tsgains five cases - the list query is scoped, the unread count is scoped, the unread count returned with a page is scoped, deleted rows are not flipped back to unread, and marking a deleted notification read is treated as not found. The existing update-criteria expectations were updated to include the scope.Verification:
npx jest src/notifications-> 6 suites, 130 tests, all passing.npx tsc --noEmit-> 66 pre-existing errors in this repo, none in the two files touched here (they are in unrelated spec and e2e fixtures).Assignment and reward are not confirmed on my side, so please treat this as a voluntary contribution. I applied for the issue on GrantFox (#1606).