feat: contribution reminder scheduler with BullMQ (closes #4)#13
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Open
Conversation
Wire up the bullmq/ioredis deps that were already in package.json but unused into a daily contribution-reminder pipeline: - BullModule.forRoot() in AppModule (Redis connection from REDIS_URL) - contribution-reminders queue + ReminderProcessor (persists a contribution_due Notification, email stubbed with a TODO) - ReminderScheduler @Cron(EVERY_DAY_AT_9AM): for each active group, enqueues a reminder for every active member who has not contributed in the current period, once the due date is within the lead window - deterministic jobId dedupes to one reminder per member per period - unit test (mocked queue + prisma) covering enqueue / outside-window / already-contributed - minimal jest config so the suite runs; REDIS_URL + period/lead env docs
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 #4
What
Wires the
bullmq+ioredisdeps (already inpackage.json, previously unused) into a working contribution-reminder pipeline.Changes
AppModule—BullModule.forRoot({ connection }), Redis connection parsed fromREDIS_URL(host/port/user/password/db).reminder.queue.ts—contribution-remindersqueue name,ReminderJobDatapayload type, andredisConnectionFromEnv()helper.ReminderProcessor(WorkerHost) — for each job payload{ groupId, memberAddress, period, dueDate }creates acontribution_dueNotificationviaNotificationsService.create(...); if the member has an email on file it logs an email intent with a// TODOnodemailer stub.ReminderScheduler—@Cron(CronExpression.EVERY_DAY_AT_9AM): for every active group, derives the current contribution period, and if the due date is within the lead window enqueues one reminder per active member who has not yet contributed that period.jobId = groupId:member:period→ exactly one reminder per member per period even though the cron runs on each day of the lead window; queue counts are logged for monitoring.Acceptance criteria
Notificationrecord created in DB when the job runsREDIS_URLNotes
contribution_period_daysfield yet, so the period length is configurable viaCONTRIBUTION_PERIOD_DAYS(default 30) andCONTRIBUTION_REMINDER_LEAD_DAYS(default 3), and the current period is derived from each group'screatedAt.currentPeriod()is isolated so a per-group governance value can drop in later without touching the enqueue logic.jestconfig block (ts-jest) so the new suite actually runs — the repo had"test": "jest"but no jest config.tscerrors onmain(stellar.service.ts,notifications.service.ts) are untouched and unrelated to this change.Verification