from .models import Order
from django.utils import timezone

def delete_expired_orders():
    expired_orders = Order.objects.filter(status=Order.STATUS_CHOICES.CANCELLED, created_at__lt=timezone.now() - timezone.timedelta(hours=24))
    count = expired_orders.count()
    expired_orders.delete()
    return count


