New alert service
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user