fix(achievements): correct batch notification date filter and bound processing - #1410
Merged
RUKAYAT-CODER merged 1 commit intoAug 31, 2026
Conversation
…rocessing sendBatchNotifications() filtered on unlockedAt: new Date(), an exact instant comparison that never matches stored rows, so scheduled batch notifications were silently never sent. Use MoreThanOrEqual(midnight today) and process the backlog in bounded chunks of 100 via take/skip pagination, matching resendFailedNotifications(). Add regression tests for the corrected date filter and bounded batching. Closes rinafcode#1391 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@ZuLu0890 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
|
Thank you for contributing to the project. |
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.
Summary
Closes #1391
AchievementsNotificationsService.sendBatchNotifications()was silently never sending scheduled batch notifications for achievements unlocked today. The query filtered onunlockedAt: new Date(), which compares against the exact current instant with millisecond precision and essentially never matches any stored row — the computed midnight boundary (today.setHours(0, 0, 0, 0)) was calculated but never used. The query was also unbounded: unlikeresendFailedNotifications(), it had notakelimit, so a fixed query would load an unbounded number of rows and send them all in a single tight loop.Changes
src/achievements/achievements-notifications.service.tsunlockedAt: new Date()withunlockedAt: MoreThanOrEqual(today), selecting achievements unlocked since midnight today that have not yet been notified (notificationSent: false). The intended "unlocked today" window is now actually applied.BATCH_SIZE = 100and process the backlog in bounded chunks usingtake/skippagination, so large backlogs are handled chunk-by-chunk instead of in one unbounded query — consistent with the existingresendFailedNotifications()behavior.while (keepProcessing)rather than a literal constant condition).src/achievements/achievements-notifications.service.spec.tsunlockedAt: MoreThanOrEqual(today)andnotificationSent: false, and that an achievement unlocked earlier today is selected and notified.Verification
All relevant checks run locally:
pnpm lint:cipnpm format:checkpnpm typecheckpnpm test src/achievements/achievements-notifications.service.spec.tsNote:
src/achievements/achievements.service.spec.tshas failing tests, but they fail identically onmain(unmodified baseline) and are unrelated to this change.