Add subcription level filtering
This commit is contained in:
@@ -82,17 +82,36 @@ class InventoryServiceClient(BaseServiceClient):
|
||||
params = {}
|
||||
if is_active is not None:
|
||||
params["is_active"] = is_active
|
||||
|
||||
|
||||
ingredients = await self.get_paginated("ingredients", tenant_id=tenant_id, params=params)
|
||||
|
||||
logger.info("Retrieved all ingredients from inventory service",
|
||||
|
||||
logger.info("Retrieved all ingredients from inventory service",
|
||||
count=len(ingredients), tenant_id=tenant_id)
|
||||
return ingredients
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Error fetching all ingredients",
|
||||
logger.error("Error fetching all ingredients",
|
||||
error=str(e), tenant_id=tenant_id)
|
||||
return []
|
||||
|
||||
async def count_ingredients(self, tenant_id: str, is_active: Optional[bool] = True) -> int:
|
||||
"""Get count of ingredients for a tenant"""
|
||||
try:
|
||||
params = {}
|
||||
if is_active is not None:
|
||||
params["is_active"] = is_active
|
||||
|
||||
result = await self.get("ingredients/count", tenant_id=tenant_id, params=params)
|
||||
count = result.get("ingredient_count", 0) if isinstance(result, dict) else 0
|
||||
|
||||
logger.info("Retrieved ingredient count from inventory service",
|
||||
count=count, tenant_id=tenant_id)
|
||||
return count
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Error fetching ingredient count",
|
||||
error=str(e), tenant_id=tenant_id)
|
||||
return 0
|
||||
|
||||
async def create_ingredient(self, ingredient_data: Dict[str, Any], tenant_id: str) -> Optional[Dict[str, Any]]:
|
||||
"""Create a new ingredient"""
|
||||
|
||||
Reference in New Issue
Block a user