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
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