27 lines
814 B
Python
27 lines
814 B
Python
|
from datetime import datetime
|
||
|
|
||
|
from celery import shared_task
|
||
|
from django.db.models import Q
|
||
|
|
||
|
from apps.warning.models import WarningLog, WarningLogStatusChoices
|
||
|
|
||
|
import logging
|
||
|
|
||
|
from apps.warning.utils.alarm import alarm_by_warning_log
|
||
|
|
||
|
logger = logging.getLogger('apps')
|
||
|
|
||
|
|
||
|
# @shared_task(name='warning_log')
|
||
|
# def warning_log():
|
||
|
# warning_logs = WarningLog.objects.filter(
|
||
|
# Q(status=WarningLogStatusChoices.CREATED) | Q(status=WarningLogStatusChoices.WARNED_AND_NEED_WARN))[:1000]
|
||
|
# for wl in warning_logs:
|
||
|
# success = alarm_by_warning_log(wl)
|
||
|
# if not success:
|
||
|
# continue
|
||
|
# if wl.status == WarningLogStatusChoices.CREATED:
|
||
|
# wl.latest_warning_time = datetime.now()
|
||
|
# wl.status = WarningLogStatusChoices.CLOSED
|
||
|
# wl.save()
|