mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +00:00
* Revert "Switch to registry for tasks (#3790)" This reverts commit 0bea2c7b561e063dcffe3c867cd244c9041c3e45. * Remove decorator
26 lines
751 B
Python
26 lines
751 B
Python
"""Tasks (processes that get offloaded) for common app."""
|
|
|
|
import logging
|
|
from datetime import datetime, timedelta
|
|
|
|
from django.core.exceptions import AppRegistryNotReady
|
|
|
|
logger = logging.getLogger('inventree')
|
|
|
|
|
|
def delete_old_notifications():
|
|
"""Remove old notifications from the database.
|
|
|
|
Anything older than ~3 months is removed
|
|
"""
|
|
try:
|
|
from common.models import NotificationEntry
|
|
except AppRegistryNotReady: # pragma: no cover
|
|
logger.info("Could not perform 'delete_old_notifications' - App registry not ready")
|
|
return
|
|
|
|
before = datetime.now() - timedelta(days=90)
|
|
|
|
# Delete notification records before the specified date
|
|
NotificationEntry.objects.filter(updated__lte=before).delete()
|