From c779b20a4f179dc4a4bf8c1731f889f77af04c25 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 13 May 2026 21:10:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=9C=80=E9=AB=98=E6=94=B9=E7=94=A8?= =?UTF-8?q?=20intraday=5Fpath=5Fsnapshots=5Fstore=EF=BC=88=E5=B7=B2?= =?UTF-8?q?=E6=9C=89=E5=AE=9E=E6=97=B6=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E9=9C=80=E7=AD=89=20Docker=20rebuild=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitoring-web/src/db.rs | 12 ++++++++---- monitoring-web/src/main.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/monitoring-web/src/db.rs b/monitoring-web/src/db.rs index 888f98b1..37bae664 100644 --- a/monitoring-web/src/db.rs +++ b/monitoring-web/src/db.rs @@ -8,14 +8,18 @@ pub struct ObsRow { pub created_at: Option, } -/// Get today's daily max temperature for an ICAO station. -pub fn get_daily_max(db_path: &str, icao: &str) -> Option<(f64, Option)> { +/// Get today's running max temperature from intraday snapshots. +pub fn get_daily_max(db_path: &str, city_key: &str) -> Option<(f64, Option)> { let conn = Connection::open(db_path).ok()?; let today = chrono::Utc::now().format("%Y-%m-%d").to_string(); let mut stmt = conn - .prepare("SELECT max_temp, max_time FROM city_daily_max WHERE icao = ?1 AND obs_date = ?2") + .prepare( + "SELECT max_so_far, snapshot_time FROM intraday_path_snapshots_store \ + WHERE city = ?1 AND target_date = ?2 \ + ORDER BY id DESC LIMIT 1" + ) .ok()?; - stmt.query_row(rusqlite::params![icao.to_uppercase(), today], |row| { + stmt.query_row(rusqlite::params![city_key, today], |row| { Ok((row.get(0)?, row.get(1)?)) }) .ok() diff --git a/monitoring-web/src/main.rs b/monitoring-web/src/main.rs index 6375b11f..f6a756f9 100644 --- a/monitoring-web/src/main.rs +++ b/monitoring-web/src/main.rs @@ -81,8 +81,8 @@ fn load_city_snapshot(db_path: &str, idx: usize, (key, _zh, en, icao, airport, t let trend_data: Vec = temps.iter().take(6).copied().collect(); let trend = trend::calc_trend(&trend_data); - // Today's max: from city_daily_max table (maintained by Python collector) - let (today_max, max_time) = db::get_daily_max(db_path, icao) + // Today's max: from intraday_path_snapshots_store (实时更新) + let (today_max, max_time) = db::get_daily_max(db_path, key) .map(|(t, mt)| (Some(t), mt)) .unwrap_or((None, None)); let new_high = match (current_temp, today_max) {