fix: optimize compliance scan performance and improve error handling
- Refactor scan_compliance to eliminate N+1 queries using joinedload and batch loading - Add try-except wrapper in compliance scan API endpoint - Improve frontend axios error interceptor to display detail/message/timeout errors - Update CORS config and nginx for domain deployment
This commit is contained in:
+3
-12
@@ -39,19 +39,9 @@ async def log_requests(request: Request, call_next):
|
||||
return response
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
db = None
|
||||
try:
|
||||
db = SessionLocal()
|
||||
body_bytes = b""
|
||||
if request.method in ["POST", "PUT", "PATCH"]:
|
||||
try:
|
||||
body_bytes = await request.body()
|
||||
# Re-assign body for downstream
|
||||
async def receive():
|
||||
return {"type": "http.request", "body": body_bytes}
|
||||
request._receive = receive
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
log_entry = log_models.OperationLog(
|
||||
module=request.url.path.split("/")[2] if len(request.url.path.split("/")) > 2 else "",
|
||||
action=request.url.path,
|
||||
@@ -66,7 +56,8 @@ async def log_requests(request: Request, call_next):
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
db.close()
|
||||
if db:
|
||||
db.close()
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user