import logging
from celery import shared_task
from django.core.management import call_command

logger = logging.getLogger(__name__)


@shared_task(name='igny8_core.purge_soft_deleted')
def purge_soft_deleted_task():
    """Periodic task to purge expired soft-deleted records."""
    try:
        call_command('purge_soft_deleted')
    except Exception as exc:
        logger.exception("purge_soft_deleted task failed: %s", exc)
        raise

