Browse Source

sendalerts was not using the api_check (status, user_id, alert_after) index so removing it. The index was not selective enough.

pull/149/head
Pēteris Caune 7 years ago
parent
commit
1392226538
3 changed files with 20 additions and 6 deletions
  1. +1
    -1
      hc/api/management/commands/sendalerts.py
  2. +19
    -0
      hc/api/migrations/0036_auto_20180116_2243.py
  3. +0
    -5
      hc/api/models.py

+ 1
- 1
hc/api/management/commands/sendalerts.py View File

@ -28,7 +28,7 @@ def notify_on_thread(check_id, stdout):
class Command(BaseCommand): class Command(BaseCommand):
help = 'Sends UP/DOWN email alerts' help = 'Sends UP/DOWN email alerts'
owned = Check.objects.filter(user__isnull=False)
owned = Check.objects.filter(user__isnull=False).order_by("alert_after")
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument( parser.add_argument(


+ 19
- 0
hc/api/migrations/0036_auto_20180116_2243.py View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-01-16 22:43
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('api', '0035_auto_20171229_2008'),
]
operations = [
migrations.AlterIndexTogether(
name='check',
index_together=set([]),
),
]

+ 0
- 5
hc/api/models.py View File

@ -57,11 +57,6 @@ def isostring(dt):
class Check(models.Model): class Check(models.Model):
class Meta:
# sendalerts command will query using these
index_together = ["status", "user", "alert_after"]
name = models.CharField(max_length=100, blank=True) name = models.CharField(max_length=100, blank=True)
tags = models.CharField(max_length=500, blank=True) tags = models.CharField(max_length=500, blank=True)
code = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True) code = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True)


Loading…
Cancel
Save