Improve AI logic
This commit is contained in:
@@ -15,8 +15,8 @@ logger = structlog.get_logger()
|
||||
class SuppliersServiceClient(BaseServiceClient):
|
||||
"""Client for communicating with the Suppliers Service"""
|
||||
|
||||
def __init__(self, config: BaseServiceSettings):
|
||||
super().__init__("suppliers", config)
|
||||
def __init__(self, config: BaseServiceSettings, calling_service_name: str = "unknown"):
|
||||
super().__init__(calling_service_name, config)
|
||||
|
||||
def get_service_base_path(self) -> str:
|
||||
return "/api/v1"
|
||||
@@ -45,9 +45,9 @@ class SuppliersServiceClient(BaseServiceClient):
|
||||
if is_active is not None:
|
||||
params["is_active"] = is_active
|
||||
|
||||
result = await self.get_paginated("suppliers/list", tenant_id=tenant_id, params=params)
|
||||
result = await self.get_paginated("suppliers", tenant_id=tenant_id, params=params)
|
||||
logger.info("Retrieved all suppliers from suppliers service",
|
||||
suppliers_count=len(result), tenant_id=tenant_id)
|
||||
suppliers_count=len(result) if result else 0, tenant_id=tenant_id)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error("Error getting all suppliers",
|
||||
@@ -59,12 +59,12 @@ class SuppliersServiceClient(BaseServiceClient):
|
||||
try:
|
||||
params = {}
|
||||
if search:
|
||||
params["search"] = search
|
||||
params["search_term"] = search
|
||||
if category:
|
||||
params["category"] = category
|
||||
params["supplier_type"] = category
|
||||
|
||||
result = await self.get("suppliers/list/search", tenant_id=tenant_id, params=params)
|
||||
suppliers = result.get('suppliers', []) if result else []
|
||||
result = await self.get("suppliers", tenant_id=tenant_id, params=params)
|
||||
suppliers = result if result else []
|
||||
logger.info("Searched suppliers from suppliers service",
|
||||
search_term=search, suppliers_count=len(suppliers), tenant_id=tenant_id)
|
||||
return suppliers
|
||||
|
||||
Reference in New Issue
Block a user