# -*- coding: utf-8 -*-
from __future__ import annotations

import logging

from celery import shared_task
from django import db

from hotpocket_backend.apps.accounts.services import AuthKeysService

LOGGER = logging.getLogger(__name__)


@shared_task
def clean_expired_auth_keys():
    with db.transaction.atomic():
        deleted_count = AuthKeysService().clean_expired_auth_keys()
        LOGGER.debug(
            'Deleted expired AuthKey objects: deleted_count=`%d`', deleted_count,
        )
