diff --git a/Cargo.lock b/Cargo.lock index 502febc..075b1d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1894,7 +1894,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "simply-dvb" -version = "0.1.17" +version = "0.1.18" dependencies = [ "anyhow", "argon2", diff --git a/Cargo.toml b/Cargo.toml index 73f5f37..a927ed8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simply-dvb" -version = "0.1.17" +version = "0.1.18" edition = "2021" rust-version = "1.85" description = "simply-dvb - lightweight DVB-T/T2/C server: scanning, HLS, M3U, EPG/XMLTV, recording and a web panel" diff --git a/src/web/tvhapi.rs b/src/web/tvhapi.rs index d087f59..409e17c 100644 --- a/src/web/tvhapi.rs +++ b/src/web/tvhapi.rs @@ -635,6 +635,18 @@ async fn status_inputs( let host_cpu = host.as_ref().and_then(|s| s.cpu); let host_proc_cpu = host.as_ref().and_then(|s| s.proc_cpu); let host_temp = host.as_ref().and_then(|s| s.temp); + // `?since=`: the samples newer than that from the statistics history the + // server keeps anyway (every 2 s, 15 minutes) – the simply-tv tuner card draws its + // charts from it, so they show the last minutes at once instead of starting empty + let hist = p + .i64("since") + .map(|since| state.stats.history(since.max(crate::db::now() - 900))); + let host_hist: Option> = hist.as_ref().map(|h| { + h.samples + .iter() + .map(|s| json!([s.t, s.cpu, s.proc_cpu])) + .collect() + }); grid( state .tuners @@ -679,6 +691,17 @@ async fn status_inputs( "packets": a.map(|a| a.ts.packets).unwrap_or(0), "status_ms": a.map(|a| a.status_ms), "read_gap_ms": a.map(|a| a.read_gap_ms), + "history": hist.as_ref().map(|h| { + h.tuners + .get(&t.id) + .map(|v| { + v.iter() + .map(|x| json!([x.t, x.strength, x.snr, x.bitrate])) + .collect::>() + }) + .unwrap_or_default() + }), + "host_history": host_hist, "server_cpu": host_cpu, "server_proc_cpu": host_proc_cpu, "server_temp": host_temp,