Add POI feature and imporve the overall backend implementation

This commit is contained in:
Urtzi Alfaro
2025-11-12 15:34:10 +01:00
parent e8096cd979
commit 5783c7ed05
173 changed files with 16862 additions and 9078 deletions

View File

@@ -9,8 +9,10 @@ from app.core.config import settings
from app.core.database import database_manager
from app.services.messaging import setup_messaging, cleanup_messaging
from shared.service_base import StandardFastAPIService
from shared.redis_utils import initialize_redis, close_redis
# Include routers
from app.api import weather_data, traffic_data, city_operations, calendar_operations, audit
from app.api import weather_data, traffic_data, city_operations, calendar_operations, audit, poi_context, geocoding, poi_refresh_jobs
from app.services.poi_scheduler import start_scheduler, stop_scheduler
class ExternalService(StandardFastAPIService):
@@ -41,7 +43,8 @@ class ExternalService(StandardFastAPIService):
# Define expected database tables for health checks
external_expected_tables = [
'weather_data', 'weather_forecasts', 'traffic_data',
'traffic_measurement_points', 'traffic_background_jobs'
'traffic_measurement_points', 'traffic_background_jobs',
'tenant_poi_contexts', 'poi_refresh_jobs'
]
# Define custom API checks
@@ -146,12 +149,25 @@ class ExternalService(StandardFastAPIService):
async def on_startup(self, app: FastAPI):
"""Custom startup logic for external service"""
pass
# Initialize Redis connection
await initialize_redis(settings.REDIS_URL, db=0, max_connections=50)
self.logger.info("Redis initialized for external service")
# Start POI refresh scheduler
await start_scheduler()
self.logger.info("POI refresh scheduler started")
async def on_shutdown(self, app: FastAPI):
"""Custom shutdown logic for external service"""
# Stop POI refresh scheduler
await stop_scheduler()
self.logger.info("POI refresh scheduler stopped")
# Close Redis connection
await close_redis()
self.logger.info("Redis connection closed")
# Database cleanup is handled by the base class
pass
def get_service_features(self):
"""Return external-specific features"""
@@ -182,4 +198,7 @@ service.add_router(audit.router)
service.add_router(weather_data.router)
service.add_router(traffic_data.router)
service.add_router(city_operations.router) # New v2.0 city-based optimized endpoints
service.add_router(calendar_operations.router) # School calendars and hyperlocal data
service.add_router(calendar_operations.router) # School calendars and hyperlocal data
service.add_router(poi_context.router) # POI detection and location-based features
service.add_router(geocoding.router) # Address search and geocoding
service.add_router(poi_refresh_jobs.router) # POI refresh background jobs