Fix LLM validation and dashboard health hot paths

This commit is contained in:
2026-03-15 13:18:51 +03:00
parent 3928455189
commit a8563a8369
24 changed files with 1398 additions and 83 deletions

View File

@@ -547,12 +547,12 @@ async def get_dashboards(
)
try:
profile_preference = profile_service.get_my_preference(current_user).preference
profile_preference = profile_service.get_dashboard_filter_binding(current_user)
normalized_username = str(
getattr(profile_preference, "superset_username_normalized", None) or ""
profile_preference.get("superset_username_normalized") or ""
).strip().lower()
raw_username = str(
getattr(profile_preference, "superset_username", None) or ""
profile_preference.get("superset_username") or ""
).strip().lower()
bound_username = normalized_username or raw_username or None
@@ -560,14 +560,14 @@ async def get_dashboards(
page_context == "dashboards_main"
and bool(apply_profile_default)
and not bool(override_show_all)
and bool(getattr(profile_preference, "show_only_my_dashboards", False))
and bool(profile_preference.get("show_only_my_dashboards", False))
and bool(bound_username)
)
can_apply_slug_filter = (
page_context == "dashboards_main"
and bool(apply_profile_default)
and not bool(override_show_all)
and bool(getattr(profile_preference, "show_only_slug_dashboards", True))
and bool(profile_preference.get("show_only_slug_dashboards", True))
)
profile_match_logic = None

View File

@@ -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]

View File

@@ -205,8 +205,7 @@ async def test_connection(
)
try:
# Simple test call
await client.client.models.list()
await client.test_runtime_connection()
return {"success": True, "message": "Connection successful"}
except Exception as e:
return {"success": False, "error": str(e)}
@@ -242,8 +241,7 @@ async def test_provider_config(
)
try:
# Simple test call
await client.client.models.list()
await client.test_runtime_connection()
return {"success": True, "message": "Connection successful"}
except Exception as e:
return {"success": False, "error": str(e)}