mirror of
https://github.com/thecyberlearn/quantumtaskai-caprover.git
synced 2026-08-18 17:32:55 +00:00
Complete Django AI agent marketplace with security optimizations and clean deployment documentation without any API keys or secrets. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
30 lines
911 B
Python
30 lines
911 B
Python
from django.core.management.base import BaseCommand
|
|
from django.utils import timezone
|
|
from agents.models import ChatSession
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Mark expired chat sessions as expired'
|
|
|
|
def handle(self, *args, **options):
|
|
now = timezone.now()
|
|
|
|
# Find active sessions that have expired
|
|
expired_sessions = ChatSession.objects.filter(
|
|
status='active',
|
|
expires_at__lt=now
|
|
)
|
|
|
|
count = expired_sessions.count()
|
|
|
|
if count > 0:
|
|
# Mark them as expired
|
|
expired_sessions.update(
|
|
status='expired',
|
|
completed_at=now
|
|
)
|
|
|
|
self.stdout.write(
|
|
self.style.SUCCESS(f'✅ Marked {count} expired sessions as expired')
|
|
)
|
|
else:
|
|
self.stdout.write('✅ No expired sessions found') |