import os
from dataclasses import dataclass


@dataclass
class Config:
    # Database
    DB_HOST: str = os.getenv("POSTGRES_HOST", "fr24-postgres")
    DB_PORT: int = int(os.getenv("POSTGRES_PORT", "5432"))
    DB_NAME: str = os.getenv("POSTGRES_DB", "fr24")
    DB_USER: str = os.getenv("POSTGRES_USER", "fr24")
    DB_PASSWORD: str = os.getenv("POSTGRES_PASSWORD", "change-me")

    # FR24 API
    FR24_API_KEY: str = os.getenv("FR24_API_KEY", "")
    FR24_API_BASE: str = "https://fr24api.flightradar24.com"

    # Airports to track
    AIRPORTS: str = "SVO,DME,VKO,ZIA"

    # Rate limit: 10 req/min for Explorer tier → 6s between requests
    RATE_LIMIT_SEC: float = float(os.getenv("FR24_RATE_LIMIT_SEC", "6.0"))

    # Pagination page size
    PAGE_SIZE: int = 100

    @property
    def DB_DSN(self) -> str:
        return (
            f"host={self.DB_HOST} port={self.DB_PORT} "
            f"dbname={self.DB_NAME} user={self.DB_USER} "
            f"password={self.DB_PASSWORD}"
        )


config = Config()
