This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-02-26 13:07:47 +00:00
|
|
|
"""passbook core tasks"""
|
2019-10-01 08:24:10 +00:00
|
|
|
from structlog import get_logger
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2020-07-20 08:57:12 +00:00
|
|
|
from passbook.core.models import ExpiringModel
|
2019-06-25 16:00:54 +00:00
|
|
|
from passbook.root.celery import CELERY_APP
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-10-04 08:08:53 +00:00
|
|
|
LOGGER = get_logger()
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
|
2019-04-04 19:49:10 +00:00
|
|
|
@CELERY_APP.task()
|
2020-07-20 08:57:12 +00:00
|
|
|
def clean_expired_models():
|
|
|
|
"""Remove expired objects"""
|
|
|
|
for cls in ExpiringModel.__subclasses__():
|
|
|
|
cls: ExpiringModel
|
|
|
|
amount, _ = cls.filter_not_expired().delete()
|
|
|
|
LOGGER.debug("Deleted expired models", model=cls, amount=amount)
|