Fix LLM validation and dashboard health hot paths
This commit is contained in:
@@ -5,27 +5,58 @@
|
||||
# @LAYER: UI/API
|
||||
# @RELATION: DEPENDS_ON -> health_service
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from fastapi import APIRouter, Depends, Query, HTTPException, status
|
||||
from typing import List, Optional
|
||||
from sqlalchemy.orm import Session
|
||||
from ...core.database import get_db
|
||||
from ...services.health_service import HealthService
|
||||
from ...schemas.health import HealthSummaryResponse
|
||||
from ...dependencies import has_permission
|
||||
from ...dependencies import has_permission, get_config_manager, get_task_manager
|
||||
|
||||
router = APIRouter(prefix="/api/health", tags=["Health"])
|
||||
|
||||
# [DEF:get_health_summary:Function]
|
||||
# @PURPOSE: Get aggregated health status for all dashboards.
|
||||
# @PRE: Caller has read permission for dashboard health view.
|
||||
# @POST: Returns HealthSummaryResponse.
|
||||
# @RELATION: CALLS -> backend.src.services.health_service.HealthService
|
||||
@router.get("/summary", response_model=HealthSummaryResponse)
|
||||
async def get_health_summary(
|
||||
environment_id: Optional[str] = Query(None),
|
||||
db: Session = Depends(get_db),
|
||||
config_manager = Depends(get_config_manager),
|
||||
_ = Depends(has_permission("plugin:migration", "READ"))
|
||||
):
|
||||
"""
|
||||
@PURPOSE: Get aggregated health status for all dashboards.
|
||||
@POST: Returns HealthSummaryResponse
|
||||
"""
|
||||
service = HealthService(db)
|
||||
service = HealthService(db, config_manager=config_manager)
|
||||
return await service.get_health_summary(environment_id=environment_id)
|
||||
# [/DEF:get_health_summary:Function]
|
||||
|
||||
# [/DEF:health_router:Module]
|
||||
|
||||
# [DEF:delete_health_report:Function]
|
||||
# @PURPOSE: Delete one persisted dashboard validation report from health summary.
|
||||
# @PRE: Caller has write permission for tasks/report maintenance.
|
||||
# @POST: Validation record is removed; linked task/logs are cleaned when available.
|
||||
# @RELATION: CALLS -> backend.src.services.health_service.HealthService
|
||||
@router.delete("/summary/{record_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def delete_health_report(
|
||||
record_id: str,
|
||||
db: Session = Depends(get_db),
|
||||
config_manager = Depends(get_config_manager),
|
||||
task_manager = Depends(get_task_manager),
|
||||
_ = Depends(has_permission("tasks", "WRITE")),
|
||||
):
|
||||
"""
|
||||
@PURPOSE: Delete a persisted dashboard validation report from health summary.
|
||||
@POST: Validation record is removed; linked task/logs are deleted when present.
|
||||
"""
|
||||
service = HealthService(db, config_manager=config_manager)
|
||||
if not service.delete_validation_report(record_id, task_manager=task_manager):
|
||||
raise HTTPException(status_code=404, detail="Health report not found")
|
||||
return
|
||||
# [/DEF:delete_health_report:Function]
|
||||
|
||||
# [/DEF:health_router:Module]
|
||||
|
||||
Reference in New Issue
Block a user