Files
zulip/zerver/management/commands/print_email_delivery_backlog.py
Alex Vandiver 0f1611286d management: Rename the deliver_email command to deliver_scheduled_email.
This makes it parallel with deliver_scheduled_messages, and clarifies
that it is not used for simply sending outgoing emails (e.g. the
`email_senders` queue).

This also renames the supervisor job to match.
2021-05-11 13:07:29 -07:00

28 lines
770 B
Python

"""
Shows backlog count of ScheduledEmail
"""
from datetime import timedelta
from typing import Any
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from zerver.models import ScheduledEmail
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_scheduled_emails command.
Usage: ./manage.py print_email_delivery_backlog
"""
def handle(self, *args: Any, **options: Any) -> None:
print(
ScheduledEmail.objects.filter(
scheduled_timestamp__lte=timezone_now() - timedelta(minutes=1)
).count()
)