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.
This commit is contained in:
Claude
2025-11-07 22:17:12 +00:00
parent 41d292913a
commit eecd630d64

View File

@@ -392,10 +392,7 @@ async def get_production_timeline(
# Fetch today's production batches # Fetch today's production batches
batches = [] batches = []
try: try:
batch_data = await production_client.get( batch_data = await production_client.get_todays_batches(tenant_id)
"/production/production-batches/today",
tenant_id=tenant_id
)
if batch_data: if batch_data:
batches = batch_data.get("batches", []) batches = batch_data.get("batches", [])
except Exception as e: except Exception as e:
@@ -442,20 +439,14 @@ async def get_insights(
# Sustainability data # Sustainability data
sustainability_data = {} sustainability_data = {}
try: try:
sustainability_data = await inventory_client.get( sustainability_data = await inventory_client.get_sustainability_widget(tenant_id) or {}
"/inventory/sustainability/widget",
tenant_id=tenant_id
) or {}
except Exception as e: except Exception as e:
logger.warning(f"Failed to fetch sustainability data: {e}") logger.warning(f"Failed to fetch sustainability data: {e}")
# Inventory data # Inventory data
inventory_data = {} inventory_data = {}
try: try:
raw_inventory_data = await inventory_client.get( raw_inventory_data = await inventory_client.get_stock_status(tenant_id)
"/inventory/dashboard/stock-status",
tenant_id=tenant_id
)
# Handle case where API returns a list instead of dict # Handle case where API returns a list instead of dict
if isinstance(raw_inventory_data, dict): if isinstance(raw_inventory_data, dict):
inventory_data = raw_inventory_data inventory_data = raw_inventory_data