修复机场高频推送:东京ICAO不匹配、釜山缺趋势数据、港/流浮频率及obs_time去重
- 东京 HIGH_FREQ_AIRPORT_ICAO 从 RJTT 改为 JMA 站号 44166 - 釜山 METAR 集群数据写入 airport_obs_log 供趋势检测 - 香港/流浮山推送间隔从 60s 改为 600s(匹配实际 10min 更新) - 新增 obs_time 去重:同一观测数据不重复推送 Constraint: JMA AMeDAS 使用站号而非 ICAO 作为站点标识 Tested: ruff check 通过
This commit is contained in:
@@ -453,6 +453,7 @@ class MetarSourceMixin:
|
||||
"lat": lat,
|
||||
"lon": lon,
|
||||
"temp": round(display_temp, 1),
|
||||
"temp_c": temp_c,
|
||||
"istNo": icao,
|
||||
"icao": icao,
|
||||
"wind_dir": obs.get("wdir"),
|
||||
|
||||
@@ -866,6 +866,23 @@ class WeatherDataCollector(OpenMeteoCacheMixin, SettlementSourceMixin, MetarSour
|
||||
if cluster_data:
|
||||
results["mgm_nearby"] = cluster_data
|
||||
results["nearby_source"] = "metar_cluster"
|
||||
# 写入 airport_obs_log,供高频推送的趋势检测使用
|
||||
try:
|
||||
from src.database.db_manager import DBManager
|
||||
db = DBManager()
|
||||
for row in cluster_data:
|
||||
icao = row.get("icao")
|
||||
temp_c = row.get("temp_c") if "temp_c" in row else row.get("temp")
|
||||
if icao and temp_c is not None:
|
||||
db.append_airport_obs(
|
||||
icao=str(icao),
|
||||
city=city_lower,
|
||||
temp_c=temp_c,
|
||||
wind_kt=row.get("wind_speed_kt"),
|
||||
obs_time=str(row.get("obs_time") or datetime.now().isoformat()),
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("airport_obs_log append failed for metar cluster city={}", city_lower)
|
||||
|
||||
def _attach_china_official_nearby(
|
||||
self, results: Dict, city_lower: str, use_fahrenheit: bool
|
||||
|
||||
Reference in New Issue
Block a user