Files
wiki/tasks/flightradar24/ingest/tracks_fr24/config.py
2026-04-26 02:10:01 +03:00

49 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 (comma-separated IATA codes)
AIRPORTS: str = os.getenv("FR24_AIRPORTS", "SVO,DME,VKO,ZIA")
# Airport direction prefix: "both:" means inbound+outbound
AIRPORT_DIRECTION_PREFIX: str = os.getenv("FR24_AIRPORT_DIR_PREFIX", "both:")
# 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 (for /full endpoint max 20000)
PAGE_SIZE: int = int(os.getenv("FR24_PAGE_SIZE", "20000"))
# Whether to fetch tracks after summaries (costs extra credits)
FETCH_TRACKS: bool = os.getenv("FR24_FETCH_TRACKS", "false").lower() == "true"
# Max pages to paginate through (safety cap). 200 × 20 = 4000 flights max
MAX_PAGES: int = int(os.getenv("FR24_MAX_PAGES", "200"))
# Credit guard: warn if estimated max flights exceeds this threshold
CREDIT_GUARD_MAX_FLIGHTS: int = int(os.getenv("FR24_CREDIT_GUARD", "2000"))
@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()