Improve the frontend 5
This commit is contained in:
@@ -228,4 +228,142 @@ class ExternalServiceClient(BaseServiceClient):
|
||||
return result
|
||||
else:
|
||||
logger.warning("No current traffic data available")
|
||||
return None
|
||||
|
||||
# ================================================================
|
||||
# CALENDAR DATA (School Calendars and Hyperlocal Information)
|
||||
# ================================================================
|
||||
|
||||
async def get_tenant_location_context(
|
||||
self,
|
||||
tenant_id: str
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get tenant location context including school calendar assignment
|
||||
"""
|
||||
logger.info("Fetching tenant location context", tenant_id=tenant_id)
|
||||
|
||||
result = await self._make_request(
|
||||
"GET",
|
||||
f"external/tenants/{tenant_id}/location-context",
|
||||
tenant_id=tenant_id,
|
||||
timeout=5.0
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info("Successfully fetched tenant location context", tenant_id=tenant_id)
|
||||
return result
|
||||
else:
|
||||
logger.info("No location context found for tenant", tenant_id=tenant_id)
|
||||
return None
|
||||
|
||||
async def get_school_calendar(
|
||||
self,
|
||||
calendar_id: str,
|
||||
tenant_id: str
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get school calendar details by ID
|
||||
"""
|
||||
logger.info("Fetching school calendar", calendar_id=calendar_id, tenant_id=tenant_id)
|
||||
|
||||
result = await self._make_request(
|
||||
"GET",
|
||||
f"external/operations/school-calendars/{calendar_id}",
|
||||
tenant_id=tenant_id,
|
||||
timeout=5.0
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info("Successfully fetched school calendar", calendar_id=calendar_id)
|
||||
return result
|
||||
else:
|
||||
logger.warning("School calendar not found", calendar_id=calendar_id)
|
||||
return None
|
||||
|
||||
async def check_is_school_holiday(
|
||||
self,
|
||||
calendar_id: str,
|
||||
check_date: str,
|
||||
tenant_id: str
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Check if a specific date is a school holiday
|
||||
|
||||
Args:
|
||||
calendar_id: School calendar UUID
|
||||
check_date: Date to check in ISO format (YYYY-MM-DD)
|
||||
tenant_id: Tenant ID for auth
|
||||
|
||||
Returns:
|
||||
Dict with is_holiday, holiday_name, etc.
|
||||
"""
|
||||
params = {"check_date": check_date}
|
||||
|
||||
logger.debug(
|
||||
"Checking school holiday status",
|
||||
calendar_id=calendar_id,
|
||||
date=check_date,
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
|
||||
result = await self._make_request(
|
||||
"GET",
|
||||
f"external/operations/school-calendars/{calendar_id}/is-holiday",
|
||||
tenant_id=tenant_id,
|
||||
params=params,
|
||||
timeout=5.0
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
async def get_city_school_calendars(
|
||||
self,
|
||||
city_id: str,
|
||||
tenant_id: str,
|
||||
school_type: Optional[str] = None,
|
||||
academic_year: Optional[str] = None
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get all school calendars for a city with optional filters
|
||||
|
||||
Args:
|
||||
city_id: City ID (e.g., "madrid")
|
||||
tenant_id: Tenant ID for auth
|
||||
school_type: Optional filter by school type
|
||||
academic_year: Optional filter by academic year
|
||||
|
||||
Returns:
|
||||
Dict with calendars list and total count
|
||||
"""
|
||||
params = {}
|
||||
if school_type:
|
||||
params["school_type"] = school_type
|
||||
if academic_year:
|
||||
params["academic_year"] = academic_year
|
||||
|
||||
logger.info(
|
||||
"Fetching school calendars for city",
|
||||
city_id=city_id,
|
||||
tenant_id=tenant_id,
|
||||
filters=params
|
||||
)
|
||||
|
||||
result = await self._make_request(
|
||||
"GET",
|
||||
f"external/operations/cities/{city_id}/school-calendars",
|
||||
tenant_id=tenant_id,
|
||||
params=params if params else None,
|
||||
timeout=5.0
|
||||
)
|
||||
|
||||
if result:
|
||||
logger.info(
|
||||
"Successfully fetched school calendars",
|
||||
city_id=city_id,
|
||||
total=result.get("total", 0)
|
||||
)
|
||||
return result
|
||||
else:
|
||||
logger.warning("No school calendars found for city", city_id=city_id)
|
||||
return None
|
||||
Reference in New Issue
Block a user