mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 15:11:09 -05:00
Removed VueJS frontend and dramatically enhanced API
This commit is contained in:
@@ -55,7 +55,9 @@ except ImportError:
|
||||
@extend_schema_view(
|
||||
get=extend_schema(
|
||||
summary="Health check",
|
||||
description="Get comprehensive health check information including system metrics.",
|
||||
description=(
|
||||
"Get comprehensive health check information including system metrics."
|
||||
),
|
||||
responses={
|
||||
200: HealthCheckOutputSerializer,
|
||||
503: HealthCheckOutputSerializer,
|
||||
@@ -104,18 +106,30 @@ class HealthCheckAPIView(APIView):
|
||||
|
||||
# Process individual health checks
|
||||
for plugin in plugins:
|
||||
plugin_name = plugin.identifier()
|
||||
# Handle both plugin objects and strings
|
||||
if hasattr(plugin, 'identifier'):
|
||||
plugin_name = plugin.identifier()
|
||||
plugin_class_name = plugin.__class__.__name__
|
||||
critical_service = getattr(plugin, "critical_service", False)
|
||||
response_time = getattr(plugin, "_response_time", None)
|
||||
else:
|
||||
# If plugin is a string, use it directly
|
||||
plugin_name = str(plugin)
|
||||
plugin_class_name = plugin_name
|
||||
critical_service = False
|
||||
response_time = None
|
||||
|
||||
plugin_errors = (
|
||||
errors.get(plugin.__class__.__name__, [])
|
||||
errors.get(plugin_class_name, [])
|
||||
if isinstance(errors, dict)
|
||||
else []
|
||||
)
|
||||
|
||||
health_data["checks"][plugin_name] = {
|
||||
"status": "healthy" if not plugin_errors else "unhealthy",
|
||||
"critical": getattr(plugin, "critical_service", False),
|
||||
"critical": critical_service,
|
||||
"errors": [str(error) for error in plugin_errors],
|
||||
"response_time_ms": getattr(plugin, "_response_time", None),
|
||||
"response_time_ms": response_time,
|
||||
}
|
||||
|
||||
# Calculate total response time
|
||||
@@ -320,6 +334,16 @@ class PerformanceMetricsAPIView(APIView):
|
||||
},
|
||||
tags=["Health"],
|
||||
),
|
||||
options=extend_schema(
|
||||
summary="CORS preflight for simple health check",
|
||||
description=(
|
||||
"Handle CORS preflight requests for the simple health check endpoint."
|
||||
),
|
||||
responses={
|
||||
200: SimpleHealthOutputSerializer,
|
||||
},
|
||||
tags=["Health"],
|
||||
),
|
||||
)
|
||||
class SimpleHealthAPIView(APIView):
|
||||
"""Simple health check endpoint for load balancers."""
|
||||
@@ -342,7 +366,7 @@ class SimpleHealthAPIView(APIView):
|
||||
"timestamp": timezone.now(),
|
||||
}
|
||||
serializer = SimpleHealthOutputSerializer(response_data)
|
||||
return Response(serializer.data)
|
||||
return Response(serializer.data, status=200)
|
||||
except Exception as e:
|
||||
response_data = {
|
||||
"status": "error",
|
||||
@@ -351,3 +375,12 @@ class SimpleHealthAPIView(APIView):
|
||||
}
|
||||
serializer = SimpleHealthOutputSerializer(response_data)
|
||||
return Response(serializer.data, status=503)
|
||||
|
||||
def options(self, request: Request) -> Response:
|
||||
"""Handle OPTIONS requests for CORS preflight."""
|
||||
response_data = {
|
||||
"status": "ok",
|
||||
"timestamp": timezone.now(),
|
||||
}
|
||||
serializer = SimpleHealthOutputSerializer(response_data)
|
||||
return Response(serializer.data)
|
||||
|
||||
Reference in New Issue
Block a user