New enterprise feature
This commit is contained in:
@@ -10,7 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from typing import Dict, Any, List, Optional
|
||||
from pydantic import BaseModel, Field
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import structlog
|
||||
import asyncio
|
||||
|
||||
from app.core.database import get_db
|
||||
@@ -27,7 +27,7 @@ from shared.clients import (
|
||||
)
|
||||
from shared.clients.procurement_client import ProcurementServiceClient
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = structlog.get_logger()
|
||||
|
||||
# Initialize service clients
|
||||
inventory_client = get_inventory_client(settings, "orchestrator")
|
||||
@@ -598,10 +598,39 @@ async def get_execution_progress(
|
||||
|
||||
async def fetch_pending_approvals():
|
||||
try:
|
||||
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100) or []
|
||||
return len(po_data) if isinstance(po_data, list) else 0
|
||||
po_data = await procurement_client.get_pending_purchase_orders(tenant_id, limit=100)
|
||||
|
||||
if po_data is None:
|
||||
logger.error(
|
||||
"Procurement client returned None for pending POs",
|
||||
tenant_id=tenant_id,
|
||||
context="likely HTTP 404 error - check URL construction"
|
||||
)
|
||||
return 0
|
||||
|
||||
if not isinstance(po_data, list):
|
||||
logger.error(
|
||||
"Unexpected response format from procurement client",
|
||||
tenant_id=tenant_id,
|
||||
response_type=type(po_data).__name__,
|
||||
response_value=str(po_data)[:200]
|
||||
)
|
||||
return 0
|
||||
|
||||
logger.info(
|
||||
"Successfully fetched pending purchase orders",
|
||||
tenant_id=tenant_id,
|
||||
count=len(po_data)
|
||||
)
|
||||
return len(po_data)
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to fetch pending approvals: {e}")
|
||||
logger.error(
|
||||
"Exception while fetching pending approvals",
|
||||
tenant_id=tenant_id,
|
||||
error=str(e),
|
||||
exc_info=True
|
||||
)
|
||||
return 0
|
||||
|
||||
# Execute in parallel
|
||||
|
||||
Reference in New Issue
Block a user