Skip to content

feat: use celery instead of cron jobs for notification digest#38185

Open
AhtishamShahid wants to merge 4 commits intomasterfrom
ahtisham/use_celery_for_notification_digest
Open

feat: use celery instead of cron jobs for notification digest#38185
AhtishamShahid wants to merge 4 commits intomasterfrom
ahtisham/use_celery_for_notification_digest

Conversation

@AhtishamShahid
Copy link
Contributor

Description

This pull request implements a significant refactor of the email digest scheduling system for notifications. The main change is the shift from using a management command and cron jobs to an automated, deduplicated, and transactional Celery-based scheduling system for daily and weekly digest emails. This ensures that digest emails are reliably scheduled and sent without duplication, even when multiple notifications arrive concurrently. The update introduces a new DigestSchedule model to track scheduled digest tasks, and deprecates the old management command. Additionally, timezone handling has been improved to use Django's timezone utilities.

Copilot AI review requested due to automatic review settings March 18, 2026 07:26
@AhtishamShahid AhtishamShahid force-pushed the ahtisham/use_celery_for_notification_digest branch from f9fb0e1 to 08402fe Compare March 18, 2026 07:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors notification digest scheduling from cron/management-command driven execution to Celery-based, deduplicated per-user scheduling backed by a new DigestSchedule model and updated time-window handling.

Changes:

  • Add configurable daily/weekly digest delivery schedule settings and a DigestSchedule model to dedupe scheduled digest tasks.
  • Trigger per-user digest scheduling from send_notifications, and introduce a new delayed Celery task flow for digest delivery.
  • Deprecate the legacy send_email_digest management command and adjust digest date-range calculation to use Django timezone utilities.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
openedx/envs/common.py Adds instance-configurable UTC delivery schedule settings for daily/weekly digests.
openedx/core/djangoapps/notifications/tasks.py Schedules digest delivery when notifications are created for daily/weekly cadence users.
openedx/core/djangoapps/notifications/models.py Introduces DigestSchedule model used as the dedupe source of truth for scheduled digest tasks.
openedx/core/djangoapps/notifications/migrations/0012_digestschedule.py Creates the DigestSchedule table and unique constraint.
openedx/core/djangoapps/notifications/management/commands/send_email_digest.py Marks the cron-driven command as deprecated and changes runtime behavior.
openedx/core/djangoapps/notifications/email/utils.py Switches digest window calculations to django.utils.timezone.now() and returns aware datetimes.
openedx/core/djangoapps/notifications/email/tasks.py Implements new digest scheduling/deduping logic and a per-user delayed Celery task flow.
openedx/core/djangoapps/notifications/email/tests/test_tasks.py Adds/updates tests for the new digest scheduling and delivery behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AhtishamShahid AhtishamShahid marked this pull request as draft March 18, 2026 08:12
@AhtishamShahid AhtishamShahid force-pushed the ahtisham/use_celery_for_notification_digest branch 2 times, most recently from 2be6343 to a33a061 Compare March 24, 2026 07:03
@AhtishamShahid AhtishamShahid marked this pull request as ready for review March 24, 2026 07:06
@AhtishamShahid AhtishamShahid force-pushed the ahtisham/use_celery_for_notification_digest branch from a33a061 to a9a82ba Compare March 24, 2026 12:00
@AhtishamShahid AhtishamShahid force-pushed the ahtisham/use_celery_for_notification_digest branch from 8dee45f to d952ef0 Compare March 25, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants