修正跑道高点缺历史时的回退来源

This commit is contained in:
2569718930@qq.com
2026-06-16 04:18:30 +08:00
parent f9d3fc2d96
commit 14e356c3c9
2 changed files with 49 additions and 1 deletions
+5 -1
View File
@@ -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")
+44
View File
@@ -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