feat: scope immediate notification email batching per user (#38866)
* feat: scope immediate notification email batching per user Immediate-email batching was scoped by user AND course_id, so a learner enrolled in multiple active courses received a separate buffered digest per course. Notification preferences are now account-level, so batching should feel account-level from the learner's perspective too. Scope the buffer by user only in decide_email_action, schedule_digest_buffer and send_buffered_digest: the first eligible notification is sent immediately, and additional immediate notifications within NOTIFICATION_IMMEDIATE_EMAIL_BUFFER_MINUTES are grouped into a single digest regardless of which course generated them. The digest already resolves per-notification course names, so multi-course digests render unchanged. course_key is retained in send_buffered_digest's signature so digest tasks enqueued before the change still deserialize. Closes openedx/tutor-contrib-platform-notifications#66 * fix: anchor buffered digest to last immediate email so wait stays buffer_minutes The digest was scheduled buffer_minutes from when the SECOND notification was processed, so the total wait after the immediate email was (gap to 2nd notification) + buffer_minutes -- observed as ~22 min for a 15 min buffer. Anchor scheduled_time to last_sent.email_sent_on + buffer_minutes instead, and clamp to now() when that window has already elapsed. Add tests for both the relative-to-last-email schedule and the already-elapsed fast path.
A
Ahtisham Shahid committed
0cbeaec1712e48562bdc9ce1452fd15a9172f430
Parent: 04fc6e4
Committed by GitHub <noreply@github.com>
on 7/14/2026, 10:05:25 AM