Add whatsapp feature
This commit is contained in:
@@ -366,4 +366,53 @@ class ExternalServiceClient(BaseServiceClient):
|
||||
return result
|
||||
else:
|
||||
logger.warning("No school calendars found for city", city_id=city_id)
|
||||
return None
|
||||
|
||||
# ================================================================
|
||||
# POI (POINT OF INTEREST) DATA
|
||||
# ================================================================
|
||||
|
||||
async def get_poi_context(
|
||||
self,
|
||||
tenant_id: str
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get POI context for a tenant including ML features for forecasting.
|
||||
|
||||
This retrieves stored POI detection results and calculated ML features
|
||||
that should be included in demand forecasting predictions.
|
||||
|
||||
Args:
|
||||
tenant_id: Tenant ID
|
||||
|
||||
Returns:
|
||||
Dict with POI context including:
|
||||
- ml_features: Dict of POI features for ML models (e.g., poi_retail_total_count)
|
||||
- poi_detection_results: Full detection results
|
||||
- location: Latitude/longitude
|
||||
- total_pois_detected: Count of POIs
|
||||
"""
|
||||
logger.info("Fetching POI context for forecasting", tenant_id=tenant_id)
|
||||
|
||||
# Note: POI context endpoint structure is /external/poi-context/{tenant_id}
|
||||
# We pass tenant_id to _make_request which will build: /api/v1/tenants/{tenant_id}/external/poi-context/{tenant_id}
|
||||
# But the actual endpoint in external service is just /poi-context/{tenant_id}
|
||||
# So we need to use the operations prefix correctly
|
||||
result = await self._make_request(
|
||||
"GET",
|
||||
f"external/operations/poi-context/{tenant_id}",
|
||||
tenant_id=None, # Don't auto-prefix, we're including tenant_id in the path
|
||||
timeout=5.0
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info(
|
||||
"Successfully fetched POI context",
|
||||
tenant_id=tenant_id,
|
||||
total_pois=result.get("total_pois_detected", 0),
|
||||
ml_features_count=len(result.get("ml_features", {}))
|
||||
)
|
||||
return result
|
||||
else:
|
||||
logger.info("No POI context found for tenant", tenant_id=tenant_id)
|
||||
return None
|
||||
Reference in New Issue
Block a user