from pydantic import BaseModel
from typing import Optional


class AirportResponse(BaseModel):
    iata: str
    name: Optional[str] = None
    city: Optional[str] = None
    state: Optional[str] = None
    lat: float
    lon: float
    total_flights: int = 0
    total_departures: int = 0
    total_arrivals: int = 0
    avg_arr_delay: Optional[float] = None
    avg_dep_delay: Optional[float] = None
    pct_delayed: Optional[float] = None
    delay_score: Optional[float] = None
    total_carrier_delay: Optional[float] = None
    total_weather_delay: Optional[float] = None
    total_nas_delay: Optional[float] = None
    total_late_aircraft_delay: Optional[float] = None
    carrier_pct: Optional[float] = None
    weather_pct: Optional[float] = None
    nas_pct: Optional[float] = None
    late_aircraft_pct: Optional[float] = None
    recovery_score: Optional[float] = None
    propagation_legs: Optional[int] = None

    class Config:
        from_attributes = True


class AirportListResponse(BaseModel):
    airports: list[AirportResponse]
    count: int
