2019-02-26 13:07:47 +00:00
|
|
|
"""passbook core tasks"""
|
2019-10-11 13:23:59 +01:00
|
|
|
from django.utils.timezone import now
|
2019-10-01 09:24:10 +01:00
|
|
|
from structlog import get_logger
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2020-05-16 15:11:53 +01:00
|
|
|
from passbook.core.models import Token
|
2019-06-25 17:00:54 +01:00
|
|
|
from passbook.root.celery import CELERY_APP
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-10-04 09:08:53 +01:00
|
|
|
LOGGER = get_logger()
|
2019-02-26 13:07:47 +00:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
|
2019-04-04 20:49:10 +01:00
|
|
|
@CELERY_APP.task()
|
2020-05-16 15:11:53 +01:00
|
|
|
def clean_tokens():
|
|
|
|
"""Remove expired tokens"""
|
|
|
|
amount, _ = Token.objects.filter(expires__lt=now(), expiring=True).delete()
|
|
|
|
LOGGER.debug("Deleted expired tokens", amount=amount)
|