New alert service

This commit is contained in:
Urtzi Alfaro
2025-12-05 20:07:01 +01:00
parent 1fe3a73549
commit 667e6e0404
393 changed files with 26002 additions and 61033 deletions

View File

@@ -449,6 +449,53 @@ class ProductionServiceClient(BaseServiceClient):
# DASHBOARD METHODS
# ================================================================
async def get_production_summary_batch(
self,
tenant_ids: List[str]
) -> Dict[str, Any]:
"""
Get production summaries for multiple tenants in a single request.
Phase 2 optimization: Eliminates N+1 query patterns for enterprise dashboards.
Args:
tenant_ids: List of tenant IDs to fetch
Returns:
Dict mapping tenant_id -> production summary
"""
try:
if not tenant_ids:
return {}
if len(tenant_ids) > 100:
logger.warning("Batch request exceeds max tenant limit", requested=len(tenant_ids))
tenant_ids = tenant_ids[:100]
result = await self.post(
"production/batch/production-summary",
data={"tenant_ids": tenant_ids},
tenant_id=tenant_ids[0] # Use first tenant for auth context
)
summaries = result if isinstance(result, dict) else {}
logger.info(
"Batch retrieved production summaries",
requested=len(tenant_ids),
found=len(summaries)
)
return summaries
except Exception as e:
logger.error(
"Error batch fetching production summaries",
error=str(e),
tenant_count=len(tenant_ids)
)
return {}
async def get_todays_batches(
self,
tenant_id: str