From 14e356c3c98e52cf1c636fa9aa2787e19f8e65b1 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Tue, 16 Jun 2026 04:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B7=91=E9=81=93=E9=AB=98?= =?UTF-8?q?=E7=82=B9=E7=BC=BA=E5=8E=86=E5=8F=B2=E6=97=B6=E7=9A=84=E5=9B=9E?= =?UTF-8?q?=E9=80=80=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/telegram_push.py | 6 ++++- tests/test_telegram_hashtags.py | 44 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/utils/telegram_push.py b/src/utils/telegram_push.py index acb8138a..3f090f61 100644 --- a/src/utils/telegram_push.py +++ b/src/utils/telegram_push.py @@ -1480,9 +1480,13 @@ def _get_airport_daily_high(city_weather: Dict[str, Any]): amos = city_weather.get("amos") or {} has_runway = bool((amos.get("runway_obs") or {}).get("point_temperatures")) if has_runway: - runway_max = _runway_history_daily_max(city_weather, city_weather.get("city") or "") + city = city_weather.get("city") or "" + runway_max = _runway_history_daily_max(city_weather, city) if runway_max is not None: return runway_max, None + current_runway_max = _focused_runway_max(str(city), city_weather) + if current_runway_max is not None: + return round(float(current_runway_max), 1), None airport = city_weather.get("airport_current") or {} max_so_far = airport.get("max_so_far") diff --git a/tests/test_telegram_hashtags.py b/tests/test_telegram_hashtags.py index 24e22f1a..622225fd 100644 --- a/tests/test_telegram_hashtags.py +++ b/tests/test_telegram_hashtags.py @@ -212,6 +212,50 @@ def test_runway_high_infers_local_today_when_payload_lacks_local_date(): assert "Today's runway high / 今日跑道高点: 35.0°C" not in text +def test_runway_high_does_not_fall_back_to_future_airport_high_when_history_missing(): + text = _build_airport_status_message( + "wuhan", + { + "city": "wuhan", + "local_date": "2026-06-16", + "utc_offset_seconds": 8 * 60 * 60, + "current": {"temp": 23.0}, + "airport_current": {"max_so_far": 29.0, "max_temp_time": "15:00"}, + "amos": { + "source": "amsc_awos", + "icao": "ZHHH", + "observation_time": "2026-06-15T20:11:00Z", + "runway_obs": { + "runway_pairs": [("04", "22"), ("05L", "23R")], + "temperatures": [(23.0, None), (23.4, None)], + "point_temperatures": [ + { + "runway": "04/22", + "tdz_temp": 23.0, + "mid_temp": None, + "end_temp": 22.8, + "target_runway_max": 23.0, + }, + { + "runway": "05L/23R", + "tdz_temp": 23.4, + "mid_temp": None, + "end_temp": 22.8, + "target_runway_max": 23.4, + }, + ], + }, + }, + }, + 29.6, + "04:11", + language="both", + ) + + assert "Today's runway high / 今日跑道高点: 23.0°C" in text + assert "Today's runway high / 今日跑道高点: 29.0°C (15:00)" not in text + + def test_telegram_slope_uses_settlement_endpoint_not_runway_max(monkeypatch): import src.utils.telegram_push as telegram_push