REFACTOR external service and improve websocket training
This commit is contained in:
6
services/external/app/models/__init__.py
vendored
6
services/external/app/models/__init__.py
vendored
@@ -16,6 +16,9 @@ from .weather import (
|
||||
WeatherForecast,
|
||||
)
|
||||
|
||||
from .city_weather import CityWeatherData
|
||||
from .city_traffic import CityTrafficData
|
||||
|
||||
# List all models for easier access
|
||||
__all__ = [
|
||||
# Traffic models
|
||||
@@ -25,4 +28,7 @@ __all__ = [
|
||||
# Weather models
|
||||
"WeatherData",
|
||||
"WeatherForecast",
|
||||
# City-based models (new)
|
||||
"CityWeatherData",
|
||||
"CityTrafficData",
|
||||
]
|
||||
|
||||
36
services/external/app/models/city_traffic.py
vendored
Normal file
36
services/external/app/models/city_traffic.py
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# services/external/app/models/city_traffic.py
|
||||
"""
|
||||
City Traffic Data Model - Shared city-based traffic storage
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, String, Integer, Float, DateTime, Text, Index
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class CityTrafficData(Base):
|
||||
"""City-based historical traffic data"""
|
||||
|
||||
__tablename__ = "city_traffic_data"
|
||||
|
||||
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
city_id = Column(String(50), nullable=False, index=True)
|
||||
date = Column(DateTime(timezone=True), nullable=False, index=True)
|
||||
|
||||
traffic_volume = Column(Integer, nullable=True)
|
||||
pedestrian_count = Column(Integer, nullable=True)
|
||||
congestion_level = Column(String(20), nullable=True)
|
||||
average_speed = Column(Float, nullable=True)
|
||||
|
||||
source = Column(String(50), nullable=False)
|
||||
raw_data = Column(JSONB, nullable=True)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), default=datetime.utcnow)
|
||||
updated_at = Column(DateTime(timezone=True), default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_city_traffic_lookup', 'city_id', 'date'),
|
||||
)
|
||||
38
services/external/app/models/city_weather.py
vendored
Normal file
38
services/external/app/models/city_weather.py
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# services/external/app/models/city_weather.py
|
||||
"""
|
||||
City Weather Data Model - Shared city-based weather storage
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, String, Float, DateTime, Text, Index
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class CityWeatherData(Base):
|
||||
"""City-based historical weather data"""
|
||||
|
||||
__tablename__ = "city_weather_data"
|
||||
|
||||
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||
city_id = Column(String(50), nullable=False, index=True)
|
||||
date = Column(DateTime(timezone=True), nullable=False, index=True)
|
||||
|
||||
temperature = Column(Float, nullable=True)
|
||||
precipitation = Column(Float, nullable=True)
|
||||
humidity = Column(Float, nullable=True)
|
||||
wind_speed = Column(Float, nullable=True)
|
||||
pressure = Column(Float, nullable=True)
|
||||
description = Column(String(200), nullable=True)
|
||||
|
||||
source = Column(String(50), nullable=False)
|
||||
raw_data = Column(JSONB, nullable=True)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), default=datetime.utcnow)
|
||||
updated_at = Column(DateTime(timezone=True), default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_city_weather_lookup', 'city_id', 'date'),
|
||||
)
|
||||
Reference in New Issue
Block a user