import datetime
from django.core.management.base import BaseCommand
from django.utils import timezone
from ...models import Clipboard 

class Command(BaseCommand):
    help = 'Delete expired entries from Clipboard'

    def handle(self, *args, **kwargs):
        now = timezone.now()
        expired_entries = Clipboard.objects.filter(expires_at__lte=now)
        count = expired_entries.count()
        expired_entries.delete()
        self.stdout.write(f'Successfully deleted {count} expired entries.')
