spug/spug_api/apps/alarm/utils.py
2020-06-14 18:30:52 +08:00

10 lines
340 B
Python

# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
# Released under the AGPL-3.0 License.
from apps.alarm.models import Alarm
from datetime import datetime, timedelta
def auto_clean_records():
date = datetime.now() - timedelta(days=30)
Alarm.objects.filter(created_at__lt=date.strftime('%Y-%m-%d')).delete()