"""Hard-delete MySeaDraw rows older than FREE_DRAW_COOLDOWN_HOURS.

The lazy cleanup inside `apps.gameboard.models.active_draw_for` already
prunes a user's stale rows on every view hit; this command is the cron
backstop for inactive accounts whose rows would otherwise sit forever.

Run from cron (or invoke manually). No flags; idempotent.

Usage:
    python manage.py delete_stale_my_sea_draws
"""
from django.core.management.base import BaseCommand

from apps.gameboard.models import MySeaDraw


class Command(BaseCommand):
    help = "Delete MySeaDraw rows older than the free-draw cooldown window (24h)."

    def handle(self, *args, **options):
        n = MySeaDraw.delete_stale()
        self.stdout.write(self.style.SUCCESS(
            f"Deleted {n} stale MySeaDraw row{'s' if n != 1 else ''}."
        ))
