From 0594e819d2e7c539c74f41a591e376f24261ec0c Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Sat, 24 Oct 2026 12:04:33 +0300 Subject: [PATCH] =?UTF-8?q?Site=20stats:=20download=20times=20in=20the=20s?= =?UTF-8?q?erver's=20zone=20(=D0=9C=D0=A1=D0=9A),=20like=20the=20days?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- website/server/src/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/website/server/src/main.rs b/website/server/src/main.rs index 2d9f3e9..d91b8c4 100644 --- a/website/server/src/main.rs +++ b/website/server/src/main.rs @@ -879,8 +879,14 @@ async fn stats(State(state): State, headers: HeaderMap) -> Response { // Android: both builds, with the downloads left out of the counts (the owner's own // tests from home show here too). - let mut android = String::from( - "

Android

", + // Times are shown in the server's zone (TZ), like the days of the summary. + let zone = match std::env::var("TZ").as_deref() { + Ok("Europe/Moscow") => "МСК".to_owned(), + Ok(z) if !z.is_empty() => z.to_owned(), + _ => "UTC".to_owned(), + }; + let mut android = format!( + "

Android

СборкаЛюди7 днейВсе, с отсеяннымиПоследнее (UTC)
", ); for platform in ["android", "android-noengine"] { let count = |cond: &str| { @@ -895,7 +901,7 @@ async fn stats(State(state): State, headers: HeaderMap) -> Response { ); let last: String = db .query_row( - "SELECT ts FROM downloads WHERE platform = ?1 ORDER BY id DESC LIMIT 1", + "SELECT datetime(ts, 'localtime') FROM downloads WHERE platform = ?1 ORDER BY id DESC LIMIT 1", [platform], |r| r.get(0), ) @@ -930,11 +936,11 @@ async fn stats(State(state): State, headers: HeaderMap) -> Response { &format!("SELECT COALESCE(referrer, 'напрямую'), COUNT(DISTINCT substr(ts, 1, 10) || visitor) {HUMAN_PV} GROUP BY 1 ORDER BY 2 DESC LIMIT 20"), ); - let mut recent = String::from( - "

Последние скачивания (без ботов; ваши и из локальной сети — серым)

СборкаЛюди7 днейВсе, с отсеяннымиПоследнее ({zone})
", + let mut recent = format!( + "

Последние скачивания (без ботов; ваши и из локальной сети — серым)

Время (UTC)ФайлВерсияГдеЯзыкОткудаКто
", ); if let Ok(mut stmt) = db.prepare( - "SELECT ts, platform, version, country, region, city, lang, referrer, kind, ua FROM downloads WHERE kind <> 'bot' ORDER BY id DESC LIMIT 50", + "SELECT datetime(ts, 'localtime'), platform, version, country, region, city, lang, referrer, kind, ua FROM downloads WHERE kind <> 'bot' ORDER BY id DESC LIMIT 50", ) { let rows = stmt.query_map([], |r| { (0..10)
Время ({zone})ФайлВерсияГдеЯзыкОткудаКто