@
新增机场高频推送:10分钟级温度监控 + DEB预测快报 为首尔/釜山/东京三大机场城市实现高频温度监控通道: - 新增 airport_obs_log 表积累观测数据,支持趋势检测 - AMOS/JMA 成功后自动写入观测日志 - 新增 airport_rapid_temp_change 告警规则(20min窗口、0.5°C/10min阈值) - 10分钟间隔高频子循环 + 30分钟机场快照(含 DEB 预测最高温) - 最高温锁定后自动跳过,快照仅当地 08:00-20:00 发送 Tested: ruff check 通过 @
This commit is contained in:
@@ -280,6 +280,21 @@ class DBManager:
|
||||
conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_supabase_bindings_telegram_id ON supabase_bindings(telegram_id)"
|
||||
)
|
||||
conn.execute("""
|
||||
CREATE TABLE IF NOT EXISTS airport_obs_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
icao TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
temp_c REAL,
|
||||
wind_kt REAL,
|
||||
pressure_hpa REAL,
|
||||
obs_time TEXT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
""")
|
||||
conn.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_airport_obs_log_icao_time ON airport_obs_log(icao, created_at DESC)"
|
||||
)
|
||||
self._ensure_column(conn, "users", "daily_points", "INTEGER DEFAULT 0")
|
||||
self._ensure_column(conn, "users", "daily_points_date", "TEXT")
|
||||
self._ensure_column(conn, "users", "weekly_points", "INTEGER DEFAULT 0")
|
||||
@@ -1825,3 +1840,43 @@ class DBManager:
|
||||
)
|
||||
conn.commit()
|
||||
return True
|
||||
|
||||
def append_airport_obs(
|
||||
self,
|
||||
*,
|
||||
icao: str,
|
||||
city: str,
|
||||
temp_c: Optional[float] = None,
|
||||
wind_kt: Optional[float] = None,
|
||||
pressure_hpa: Optional[float] = None,
|
||||
obs_time: str,
|
||||
) -> None:
|
||||
with self._get_connection() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO airport_obs_log (icao, city, temp_c, wind_kt, pressure_hpa, obs_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(str(icao).strip().upper(), str(city).strip().lower(),
|
||||
temp_c, wind_kt, pressure_hpa, str(obs_time)),
|
||||
)
|
||||
conn.execute(
|
||||
"DELETE FROM airport_obs_log WHERE created_at < datetime('now', '-2 hours')"
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
def get_airport_obs_recent(
|
||||
self, icao: str, minutes: int = 30
|
||||
) -> list[dict[str, Any]]:
|
||||
with self._get_connection() as conn:
|
||||
conn.row_factory = sqlite3.Row
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT icao, city, temp_c, wind_kt, pressure_hpa, obs_time, created_at
|
||||
FROM airport_obs_log
|
||||
WHERE icao = ? AND created_at >= datetime('now', ? || ' minutes')
|
||||
ORDER BY created_at ASC
|
||||
""",
|
||||
(str(icao).strip().upper(), str(-int(minutes))),
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
Reference in New Issue
Block a user