Fix issues

This commit is contained in:
Urtzi Alfaro
2025-07-18 11:51:43 +02:00
parent 9391368b83
commit 592a810762
35 changed files with 3806 additions and 122 deletions

View File

@@ -0,0 +1,29 @@
# ================================================================
# services/data/app/models/traffic.py
# ================================================================
"""Traffic data models"""
from sqlalchemy import Column, String, DateTime, Float, Integer, Text, Index
from sqlalchemy.dialects.postgresql import UUID
import uuid
from datetime import datetime
from app.core.database import Base
class TrafficData(Base):
__tablename__ = "traffic_data"
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
location_id = Column(String(100), nullable=False, index=True)
date = Column(DateTime, nullable=False, index=True)
traffic_volume = Column(Integer, nullable=True) # vehicles per hour
pedestrian_count = Column(Integer, nullable=True) # pedestrians per hour
congestion_level = Column(String(20), nullable=True) # low/medium/high
average_speed = Column(Float, nullable=True) # km/h
source = Column(String(50), nullable=False, default="madrid_opendata")
raw_data = Column(Text, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
__table_args__ = (
Index('idx_traffic_location_date', 'location_id', 'date'),
)