reminders: adjust and explain sending time (#46713)

This commit is contained in:
Valentin Deniaud 2020-09-17 13:57:49 +02:00 committed by Frédéric Péters
parent c4c7681e3e
commit c513f4b16b
1 changed files with 8 additions and 2 deletions

View File

@ -42,10 +42,16 @@ class Command(BaseCommand):
def handle(self, **options):
translation.activate(settings.LANGUAGE_CODE)
# We want to send reminders x days before event starts, say x=2. For
# that we look at events that begin no earlier than 2 days minus 6
# hours from now, AND no later than 2 days. Hence an event that is in 2
# days will only be in this range from exactly 2 days before to 2 days
# before plus 6 hours. In case command is ran once every hour and a
# sending fails, this allows 6 retries before giving up.
reminder_delta = F('event__agenda__reminder_settings__days') * timedelta(1)
starts_before = timezone.now() + reminder_delta
# 12 hours time window to run the command and send reminder, thus excluding old events
starts_after = timezone.now() + reminder_delta - timedelta(hours=12)
starts_after = timezone.now() + reminder_delta - timedelta(hours=6)
# prevent user who just booked from getting a reminder
created_before = timezone.now() - timedelta(hours=12)