Skip to content

Commit

Permalink
Configurable day to send weekly notification digest emails on (#3475)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathjazz authored Dec 9, 2024
1 parent 44ab754 commit 3090235
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/admin/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ you create:
Optional. Name to give to this app on New Relic. Required if you're using
New Relic.

``NOTIFICATION_DIGEST_DAY``
Optional. Integer representing a day of the week on which the weekly notification
digest email will be sent. 0 represents Monday, 6 represents Sunday. The default
value is 4 (Friday).

``OPENAI_API_KEY``
Optional. Set your `OpenAI API` key to add the ability to refine machine
translations using ChatGPT.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.timezone import now
from django.utils.timezone import datetime

from pontoon.messaging.emails import send_notification_digest

Expand All @@ -10,6 +11,6 @@ class Command(BaseCommand):
def handle(self, *args, **options):
send_notification_digest(frequency="Daily")

# Only send weekly digests on Saturdays
if now().isoweekday() == 6:
# Send the weekly notification digest only on the configured day (e.g. Friday)
if datetime.today().weekday() == settings.NOTIFICATION_DIGEST_DAY:
send_notification_digest(frequency="Weekly")
8 changes: 7 additions & 1 deletion pontoon/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,15 @@ def account_username(user):
NOTIFICATIONS_MAX_COUNT = 7

# Integer representing a day of the week on which the `send_suggestion_notifications`
# management command will run.
# management command will run. 0 represents Monday, 6 represents Sunday. The default
# value is 4 (Friday).
SUGGESTION_NOTIFICATIONS_DAY = os.environ.get("SUGGESTION_NOTIFICATIONS_DAY", 4)

# Integer representing a day of the week on which the weekly notification digest
# email will be sent. 0 represents Monday, 6 represents Sunday. The default value
# is 4 (Friday).
NOTIFICATION_DIGEST_DAY = os.environ.get("NOTIFICATION_DIGEST_DAY", 4)

# Date from which badge data collection starts
badges_start_date = os.environ.get("BADGES_START_DATE", "1970-01-01")
try:
Expand Down

0 comments on commit 3090235

Please sign in to comment.