推送频率改为按数据源原生速率:AMOS 1分钟,其余 10分钟
不再统一 2 分钟,各城市按实际数据刷新周期独立推送: 首尔/釜山 60s,东京/安卡拉/赫尔辛基/阿姆斯特丹 600s。 循环轮询间隔降至 60s 以匹配最快频率。 Constraint: 循环每 60s 跑一轮,但 interval 判断让各城市按自有节奏推送 Tested: pytest 176 passed, ruff check 通过
This commit is contained in:
@@ -186,7 +186,7 @@ class StartupCoordinator:
|
|||||||
def _start_airport_high_freq_loop(self) -> LoopStatus:
|
def _start_airport_high_freq_loop(self) -> LoopStatus:
|
||||||
enabled = _env_bool("TELEGRAM_AIRPORT_PUSH_ENABLED", True)
|
enabled = _env_bool("TELEGRAM_AIRPORT_PUSH_ENABLED", True)
|
||||||
chat_ids = get_telegram_chat_ids_from_env()
|
chat_ids = get_telegram_chat_ids_from_env()
|
||||||
interval = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 120))
|
interval = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 60))
|
||||||
details = {
|
details = {
|
||||||
"mode": "airport-periodic",
|
"mode": "airport-periodic",
|
||||||
"interval_sec": interval,
|
"interval_sec": interval,
|
||||||
|
|||||||
@@ -752,7 +752,15 @@ def _build_airport_status_message(
|
|||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
_AIRPORT_PUSH_INTERVAL_SEC = 120
|
# Per-city push interval matching native data refresh rate (seconds)
|
||||||
|
_AIRPORT_PUSH_INTERVAL = {
|
||||||
|
"seoul": 60, # AMOS 1-min
|
||||||
|
"busan": 60, # AMOS 1-min
|
||||||
|
"tokyo": 600, # JMA 10-min
|
||||||
|
"ankara": 600, # MGM ~10-min
|
||||||
|
"helsinki": 600, # FMI 10-min
|
||||||
|
"amsterdam": 600, # KNMI 10-min
|
||||||
|
}
|
||||||
_DEB_PROXIMITY_THRESHOLD_C = 3.0
|
_DEB_PROXIMITY_THRESHOLD_C = 3.0
|
||||||
|
|
||||||
|
|
||||||
@@ -770,7 +778,8 @@ def _run_high_freq_airport_cycle(
|
|||||||
try:
|
try:
|
||||||
last_city = last_by_city.get(city) or {}
|
last_city = last_by_city.get(city) or {}
|
||||||
last_city_ts = int(last_city.get("ts") or 0)
|
last_city_ts = int(last_city.get("ts") or 0)
|
||||||
if now_ts - last_city_ts < _AIRPORT_PUSH_INTERVAL_SEC:
|
city_interval = _AIRPORT_PUSH_INTERVAL.get(city, 600)
|
||||||
|
if now_ts - last_city_ts < city_interval:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
city_weather: Dict[str, Any] = {}
|
city_weather: Dict[str, Any] = {}
|
||||||
@@ -851,7 +860,7 @@ def start_high_freq_airport_push_loop(bot: Any, config: Dict[str, Any]) -> Optio
|
|||||||
logger.warning("airport high-freq push loop skipped: TELEGRAM_CHAT_IDS is not set")
|
logger.warning("airport high-freq push loop skipped: TELEGRAM_CHAT_IDS is not set")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
interval_sec = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", _AIRPORT_PUSH_INTERVAL_SEC))
|
interval_sec = max(30, _env_int("TELEGRAM_AIRPORT_PUSH_INTERVAL_SEC", 60))
|
||||||
|
|
||||||
def _runner() -> None:
|
def _runner() -> None:
|
||||||
state = _load_airport_state()
|
state = _load_airport_state()
|
||||||
|
|||||||
Reference in New Issue
Block a user