Claude
413f652bbc
fix: Align dashboard API calls with actual procurement and production service endpoints
CRITICAL FIX: Dashboard was calling non-existent API endpoints
The Problem:
------------
The orchestrator dashboard service was calling API endpoints that don't exist:
1. Procurement: Expected dict {items: [...]} but API returns array [...]
2. Production: Called /production/production-batches/today - doesn't exist
3. Production: Called /production/production-batches - doesn't exist
Root Cause:
-----------
Created client methods without verifying actual backend API structure.
Made assumptions about response formats that didn't match reality.
The Fix:
--------
**1. Procurement Client (shared/clients/procurement_client.py)**
- Fixed get_pending_purchase_orders return type: Dict → List
- Procurement API returns: List[PurchaseOrderResponse] directly
- Changed: "Dict with {items: [...], total: n}" → "List of purchase order dicts"
**2. Production Client (shared/clients/production_client.py)**
- Fixed get_todays_batches endpoint:
OLD: "/production/production-batches/today" (doesn't exist)
NEW: "/production/batches?start_date=today&end_date=today"
- Fixed get_production_batches_by_status endpoint:
OLD: "/production/production-batches?status=X"
NEW: "/production/batches?status=X"
- Updated return type docs: {"items": [...]} → {"batches": [...], "total_count": n}
- Response structure: ProductionBatchListResponse (batches, total_count, page, page_size)
**3. Orchestrator Dashboard API (services/orchestrator/app/api/dashboard.py)**
- Fixed all po_data access patterns:
OLD: po_data.get("items", [])
NEW: direct list access or po_data if isinstance(po_data, list)
- Fixed production batch access:
OLD: prod_data.get("items", [])
NEW: prod_data.get("batches", [])
- Updated 6 locations:
* Line 206: health-status pending POs count
* Line 216: health-status production delays count
* Line 274-281: orchestration-summary PO summaries
* Line 328-329: action-queue pending POs
* Line 472-487: insights deliveries calculation
* Line 499-519: insights savings calculation
Verified Against:
-----------------
Frontend successfully calls these exact APIs:
- /tenants/{id}/procurement/purchase-orders (ProcurementPage.tsx)
- /tenants/{id}/production/batches (production hooks)
Both return arrays/objects as documented in their respective API files:
- services/procurement/app/api/purchase_orders.py: returns List[PurchaseOrderResponse]
- services/production/app/api/production_batches.py: returns ProductionBatchListResponse
Now dashboard calls match actual backend APIs! ✅
2025-11-08 06:56:30 +00:00
..
2025-11-05 13:34:56 +01:00
2025-10-31 11:54:19 +01:00
2025-11-08 06:56:30 +00:00
2025-11-05 13:34:56 +01:00
2025-10-30 21:08:07 +01:00
2025-10-12 23:16:04 +02:00
2025-10-09 14:11:02 +02:00
2025-11-02 20:24:44 +01:00
2025-10-15 16:12:49 +02:00
2025-11-05 13:34:56 +01:00
2025-10-27 16:33:26 +01:00
2025-11-07 19:47:12 +00:00
2025-10-12 18:47:33 +02:00
2025-10-29 06:58:05 +01:00
2025-10-31 11:54:19 +01:00
2025-10-17 18:14:28 +02:00
2025-11-07 19:22:02 +00:00
2025-10-24 13:05:04 +02:00
2025-10-15 16:12:49 +02:00
2025-10-21 19:50:07 +02:00