New alert system and panel de control page
This commit is contained in:
@@ -94,6 +94,54 @@ class AlertsServiceClient(BaseServiceClient):
|
||||
logger.error("Error fetching critical alerts", error=str(e), tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def get_alerts(
|
||||
self,
|
||||
tenant_id: str,
|
||||
priority_level: Optional[str] = None,
|
||||
status: Optional[str] = None,
|
||||
resolved: Optional[bool] = None,
|
||||
limit: int = 100,
|
||||
offset: int = 0
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get alerts with optional filters
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
priority_level: Filter by priority level (critical, important, standard, info)
|
||||
status: Filter by status (active, resolved, acknowledged, ignored)
|
||||
resolved: Filter by resolved status (None = all, True = resolved only, False = unresolved only)
|
||||
limit: Maximum number of alerts
|
||||
offset: Pagination offset
|
||||
|
||||
Returns:
|
||||
Dict with:
|
||||
{
|
||||
"alerts": [...],
|
||||
"total": int,
|
||||
"limit": int,
|
||||
"offset": int
|
||||
}
|
||||
"""
|
||||
try:
|
||||
params = {"limit": limit, "offset": offset}
|
||||
if priority_level:
|
||||
params["priority_level"] = priority_level
|
||||
if status:
|
||||
params["status"] = status
|
||||
if resolved is not None:
|
||||
params["resolved"] = resolved
|
||||
|
||||
return await self.get(
|
||||
"/alerts",
|
||||
tenant_id=tenant_id,
|
||||
params=params
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error("Error fetching alerts",
|
||||
error=str(e), tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def get_alerts_by_severity(
|
||||
self,
|
||||
tenant_id: str,
|
||||
@@ -153,6 +201,44 @@ class AlertsServiceClient(BaseServiceClient):
|
||||
alert_id=alert_id, tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def get_dashboard_analytics(
|
||||
self,
|
||||
tenant_id: str,
|
||||
days: int = 7
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get dashboard analytics including prevented issues and estimated savings
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
days: Number of days to analyze (default: 7)
|
||||
|
||||
Returns:
|
||||
Dict with analytics data:
|
||||
{
|
||||
"period_days": int,
|
||||
"total_alerts": int,
|
||||
"active_alerts": int,
|
||||
"ai_handling_rate": float,
|
||||
"prevented_issues_count": int,
|
||||
"estimated_savings_eur": float,
|
||||
"total_financial_impact_at_risk_eur": float,
|
||||
"priority_distribution": {...},
|
||||
"type_class_distribution": {...},
|
||||
"active_by_type_class": {...},
|
||||
"period_comparison": {...}
|
||||
}
|
||||
"""
|
||||
try:
|
||||
return await self.get(
|
||||
"/alerts/analytics/dashboard",
|
||||
tenant_id=tenant_id,
|
||||
params={"days": days}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error("Error fetching dashboard analytics", error=str(e), tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
# ================================================================
|
||||
# UTILITY METHODS
|
||||
# ================================================================
|
||||
|
||||
Reference in New Issue
Block a user