From 371e5ef7cd67b0d3d29b53765e643ec88cf9a09b Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 3 Dec 2024 20:13:05 +0100 Subject: [PATCH] feat: make batchsize customizable too --- src/api.rs | 3 ++- src/config.rs | 3 +++ web/index.html | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api.rs b/src/api.rs index 32db3f4..d44e541 100644 --- a/src/api.rs +++ b/src/api.rs @@ -8,7 +8,8 @@ pub async fn serve(config: Config, db: Database, addr: &str) -> std::io::Result< // whats a jinja let index = include_str!("../web/index.html") .replacen("%%DESCRIPTION%%", config.description.as_deref().unwrap_or("keeping track of your infra's up status"), 1) - .replacen("%%THRESHOLD%%", &config.threshold.unwrap_or(1000).to_string(), 1); + .replacen("%%THRESHOLD%%", &config.threshold.unwrap_or(1000).to_string(), 1) + .replacen("%%BATCHSIZE%%", &config.batchsize.unwrap_or(120).to_string(), 1); let app = axum::Router::new() .route("/", axum::routing::get(|| async { Html(index) })) diff --git a/src/config.rs b/src/config.rs index 9365abe..74858fe 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,6 +10,9 @@ pub struct Config { /// requests taking longer than this limit (in ms) will be marked as "slow" in FE pub threshold: Option, + /// how many samples to provide to web frontend + pub batchsize: Option, + // TODO reintroduce this! should allow to optionally trim db periodically /// how many samples of history to keep //history: usize, diff --git a/web/index.html b/web/index.html index ce4da5c..52381a2 100644 --- a/web/index.html +++ b/web/index.html @@ -176,7 +176,7 @@ async function updateStatus() { let out = ""; for (let key of keys) { - let res = await fetch(`/api/status/${key}?limit=120`); + let res = await fetch(`/api/status/${key}?limit=%%BATCHSIZE%%`); let history = await res.json(); out += card(key, history, status[key]); out += "\n";