|
|
@ -82,9 +82,6 @@ class Command(BaseCommand): |
|
|
|
|
|
|
|
now = timezone.now() |
|
|
|
|
|
|
|
# In PostgreSQL, add this index to run the below query efficiently: |
|
|
|
# CREATE INDEX api_check_up ON api_check (alert_after) WHERE status = 'up' |
|
|
|
|
|
|
|
q = Check.objects.filter(alert_after__lt=now).exclude(status="down") |
|
|
|
# Sort by alert_after, to avoid unnecessary sorting by id: |
|
|
|
check = q.order_by("alert_after").first() |
|
|
|