Skip to content

feat: scope immediate notification email batching per user (backport #38866)#38886

Merged
AhtishamShahid merged 1 commit into
release/verawoodfrom
ahtisham/backport-38866-verawood
Jul 14, 2026
Merged

feat: scope immediate notification email batching per user (backport #38866)#38886
AhtishamShahid merged 1 commit into
release/verawoodfrom
ahtisham/backport-38866-verawood

Conversation

@AhtishamShahid

Copy link
Copy Markdown
Contributor

Backport of #38866 to release/verawood.

Cherry-pick of merged commit 0cbeaec1712e48562bdc9ce1452fd15a9172f430 (squash of #38866). Applied cleanly with no conflicts.

Original PR summary

Scopes the immediate-notification email batching per user instead of per user+course:

  • decide_email_action no longer filters recent notifications by course_id, so a recent immediate email for any enrolled course now buffers subsequent immediate notifications into one digest.
  • schedule_digest_buffer anchors the digest ETA to the user's last immediate email (last_sent.email_sent_on + buffer_minutes), falling back to now if that window already elapsed.
  • send_buffered_digest collects all scheduled notifications for the user across every course; course_key is retained in signatures for compatibility but no longer filters.
  • Tests updated to match the per-user batching behavior.

Original PR: #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.
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 14, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @AhtishamShahid!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@AhtishamShahid AhtishamShahid merged commit 0a675f5 into release/verawood Jul 14, 2026
46 checks passed
@AhtishamShahid AhtishamShahid deleted the ahtisham/backport-38866-verawood branch July 14, 2026 14:40
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants