示例#1
0
def send_activity_digest(user_id, subject, preference):
    """Individual task to create and send an activity digest to a user."""
    user = User.objects.get(id=user_id)
    interval = {
        "hourly": relativedelta(hours=1),
        "daily": relativedelta(days=1),
        "weekly": relativedelta(weeks=1),
        "monthly": relativedelta(months=1),
    }[preference]

    logger.info(
        "Starting activity digest at: %s User: %s Subject: %s Interval: %s",
        timezone.now(),
        user,
        subject,
        interval,
    )
    try:
        email = digests.ActivityDigest(user=user,
                                       subject=subject,
                                       interval=interval)
        email.send()
    except SoftTimeLimitExceeded:
        logger.error(
            "Send Activity Digest took too long. "
            "User: %s, Subject: %s, Interval %s",
            user,
            subject,
            interval,
        )
示例#2
0
def send_activity_digest(user, subject, interval):
    """Individual task to create and send an activity digest to a user."""
    email = digests.ActivityDigest(
        user=user,
        subject=subject,
        interval=interval,
    )
    email.send()
示例#3
0
def send_activity_digest(user, subject, interval):
    """Individual task to create and send an activity digest to a user."""
    try:
        email = digests.ActivityDigest(
            user=user,
            subject=subject,
            interval=interval,
        )
        email.send()
    except SoftTimeLimitExceeded:
        logger.error(
            'Send Activity Digest took too long. '
            'User: %s, Subject: %s, Interval %s', user, subject, interval)