Files
zulip/zerver/management/commands/enqueue_digest_emails.py
Aditya Bansal d9c9bfe7f6 logger: Add new create_logger abstraction to simplify logging.
This deduplicates a ton of Python logger-creation code to use a single
standard implementation, so we can avoid copy-paste problems.
2017-08-27 18:31:53 -07:00

25 lines
728 B
Python

from __future__ import absolute_import
import datetime
from typing import Any, List
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from zerver.lib.digest import enqueue_emails, DIGEST_CUTOFF
from zerver.lib.logging_util import create_logger
## Logging setup ##
logger = create_logger(__name__, settings.DIGEST_LOG_PATH, 'DEBUG')
class Command(BaseCommand):
help = """Enqueue digest emails for users that haven't checked the app
in a while.
"""
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
cutoff = timezone_now() - datetime.timedelta(days=DIGEST_CUTOFF)
enqueue_emails(cutoff)