Site stats: download times in the server's zone (МСК), like the days
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
78ef78fda1
commit
0594e819d2
1 changed files with 12 additions and 6 deletions
|
|
@ -879,8 +879,14 @@ async fn stats(State(state): State<Shared>, 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(
|
||||
"<section class=wide><h2>Android</h2><table><tr><th>Сборка</th><th class=num>Люди</th><th class=num>7 дней</th><th class=num>Все, с отсеянными</th><th>Последнее (UTC)</th></tr>",
|
||||
// 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!(
|
||||
"<section class=wide><h2>Android</h2><table><tr><th>Сборка</th><th class=num>Люди</th><th class=num>7 дней</th><th class=num>Все, с отсеянными</th><th>Последнее ({zone})</th></tr>",
|
||||
);
|
||||
for platform in ["android", "android-noengine"] {
|
||||
let count = |cond: &str| {
|
||||
|
|
@ -895,7 +901,7 @@ async fn stats(State(state): State<Shared>, 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<Shared>, 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(
|
||||
"<section class=wide><h2>Последние скачивания (без ботов; ваши и из локальной сети — серым)</h2><table class=recent><tr><th>Время (UTC)</th><th>Файл</th><th>Версия</th><th>Где</th><th>Язык</th><th>Откуда</th><th>Кто</th></tr>",
|
||||
let mut recent = format!(
|
||||
"<section class=wide><h2>Последние скачивания (без ботов; ваши и из локальной сети — серым)</h2><table class=recent><tr><th>Время ({zone})</th><th>Файл</th><th>Версия</th><th>Где</th><th>Язык</th><th>Откуда</th><th>Кто</th></tr>",
|
||||
);
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue