From eecd630d646b56de738755d139cba50610a95c22 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Nov 2025 22:17:12 +0000 Subject: [PATCH] refactor: Use dedicated service client methods throughout dashboard Completed migration from generic .get() calls to typed service client methods for better code clarity and maintainability. Changes: - Production timeline: Use get_todays_batches() instead of .get() - Insights: Use get_sustainability_widget() and get_stock_status() All dashboard endpoints now use domain-specific typed methods instead of raw HTTP paths, making the code more discoverable and type-safe. --- services/orchestrator/app/api/dashboard.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/services/orchestrator/app/api/dashboard.py b/services/orchestrator/app/api/dashboard.py index 483db79f..4bf7bdb6 100644 --- a/services/orchestrator/app/api/dashboard.py +++ b/services/orchestrator/app/api/dashboard.py @@ -392,10 +392,7 @@ async def get_production_timeline( # Fetch today's production batches batches = [] try: - batch_data = await production_client.get( - "/production/production-batches/today", - tenant_id=tenant_id - ) + batch_data = await production_client.get_todays_batches(tenant_id) if batch_data: batches = batch_data.get("batches", []) except Exception as e: @@ -442,20 +439,14 @@ async def get_insights( # Sustainability data sustainability_data = {} try: - sustainability_data = await inventory_client.get( - "/inventory/sustainability/widget", - tenant_id=tenant_id - ) or {} + sustainability_data = await inventory_client.get_sustainability_widget(tenant_id) or {} except Exception as e: logger.warning(f"Failed to fetch sustainability data: {e}") # Inventory data inventory_data = {} try: - raw_inventory_data = await inventory_client.get( - "/inventory/dashboard/stock-status", - tenant_id=tenant_id - ) + raw_inventory_data = await inventory_client.get_stock_status(tenant_id) # Handle case where API returns a list instead of dict if isinstance(raw_inventory_data, dict): inventory_data = raw_inventory_data