diff --git a/apps/schedulers/tasks.py b/apps/schedulers/tasks.py index 98ae181..49634c8 100644 --- a/apps/schedulers/tasks.py +++ b/apps/schedulers/tasks.py @@ -8,7 +8,7 @@ import math import requests.exceptions as rex -from django.db.models import Sum +from django.db.models import Sum, Min from django.core.cache import cache from django.db.models import Q @@ -587,6 +587,10 @@ def load_asd(): WHERE EventCountInMinute >= 3 """ + duplicates = GtoAlarm.objects.values('alarmid').annotate( + min_id=Min('id')).values('min_id') + GtoAlarm.objects.exclude(id__in=duplicates).delete() + cursor = connection.cursor() cursor.execute(sql_query)