mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
ScheduledJob was written for much more generality than it ended up being used for. Currently it is used by send_future_email, and nothing else. Tailoring the model to emails in particular will make it easier to do things like selectively clear emails when people unsubscribe from particular email types, or seamlessly handle using the same email on multiple realms.
32 lines
882 B
Python
Executable File
32 lines
882 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
"""
|
|
Shows backlog count of ScheduledEmail
|
|
"""
|
|
|
|
from __future__ import absolute_import
|
|
from __future__ import print_function
|
|
|
|
from typing import Any
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand
|
|
from django.utils.timezone import now as timezone_now
|
|
|
|
from zerver.models import ScheduledEmail
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
class Command(BaseCommand):
|
|
help = """Shows backlog count of ScheduledEmail
|
|
(The number of currently overdue (by at least a minute) email jobs)
|
|
|
|
This is run as part of the nagios health check for the deliver_email command.
|
|
|
|
Usage: ./manage.py print_email_delivery_backlog
|
|
"""
|
|
|
|
def handle(self, *args, **options):
|
|
# type: (*Any, **Any) -> None
|
|
print(ScheduledEmail.objects.filter(
|
|
scheduled_timestamp__lte=timezone_now()-timedelta(minutes=1)).count())
|