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

@@ -655,6 +655,53 @@ class InventoryServiceClient(BaseServiceClient):
# DASHBOARD METHODS
# ================================================================
async def get_inventory_summary_batch(
self,
tenant_ids: List[str]
) -> Dict[str, Any]:
"""
Get inventory 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 -> inventory 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(
"inventory/batch/inventory-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 inventory summaries",
requested=len(tenant_ids),
found=len(summaries)
)
return summaries
except Exception as e:
logger.error(
"Error batch fetching inventory summaries",
error=str(e),
tenant_count=len(tenant_ids)
)
return {}
async def get_stock_status(
self,
tenant_id: str
@@ -692,7 +739,7 @@ class InventoryServiceClient(BaseServiceClient):
"""
try:
return await self.get(
"/inventory/sustainability/widget",
"/sustainability/widget",
tenant_id=tenant_id
)
except Exception as e: