feat: Implement initial schema and add various API, service, and management command enhancements across the application.

This commit is contained in:
pacnpal
2026-01-01 15:13:01 -05:00
parent c95f99ca10
commit b243b17af7
413 changed files with 11164 additions and 17433 deletions

View File

@@ -4,6 +4,7 @@ Server-Sent Events (SSE) endpoint for real-time moderation dashboard updates.
This module provides a streaming HTTP response that broadcasts submission status
changes to connected moderators in real-time.
"""
import json
import logging
import queue
@@ -103,6 +104,7 @@ class ModerationSSEView(APIView):
Sends a heartbeat every 30 seconds to keep the connection alive.
"""
def event_stream() -> Generator[str]:
client_queue = sse_broadcaster.subscribe()
@@ -124,13 +126,10 @@ class ModerationSSEView(APIView):
finally:
sse_broadcaster.unsubscribe(client_queue)
response = StreamingHttpResponse(
event_stream(),
content_type='text/event-stream'
)
response['Cache-Control'] = 'no-cache'
response['X-Accel-Buffering'] = 'no' # Disable nginx buffering
response['Connection'] = 'keep-alive'
response = StreamingHttpResponse(event_stream(), content_type="text/event-stream")
response["Cache-Control"] = "no-cache"
response["X-Accel-Buffering"] = "no" # Disable nginx buffering
response["Connection"] = "keep-alive"
return response
@@ -168,15 +167,17 @@ class ModerationSSETestView(APIView):
sse_broadcaster.broadcast(test_payload)
return JsonResponse({
"status": "ok",
"message": f"Test event broadcast to {len(sse_broadcaster._subscribers)} clients",
"payload": test_payload,
})
return JsonResponse(
{
"status": "ok",
"message": f"Test event broadcast to {len(sse_broadcaster._subscribers)} clients",
"payload": test_payload,
}
)
__all__ = [
'ModerationSSEView',
'ModerationSSETestView',
'sse_broadcaster',
"ModerationSSEView",
"ModerationSSETestView",
"sse_broadcaster",
]