From 0c42818d2fd2f5f216b226455bf6f87303fca519 Mon Sep 17 00:00:00 2001 From: Bauke Date: Wed, 14 Jun 2023 12:44:41 +0200 Subject: [PATCH] Output untruncated charts. --- source/charts/mod.rs | 9 +++++++-- source/cli/run.rs | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/source/charts/mod.rs b/source/charts/mod.rs index 7ed85ab..15c90e5 100644 --- a/source/charts/mod.rs +++ b/source/charts/mod.rs @@ -28,8 +28,13 @@ impl UserCountChart { parent: &PathBuf, group_name: &str, render_point_circles: bool, + truncate: bool, ) -> Result { - let parent = parent.join("charts/user-count"); + let parent = if truncate { + parent.join("charts/user-count") + } else { + parent.join("charts-untruncated/user-count") + }; create_dir_all(&parent).await?; let (mut datapoints, mut min_count, mut max_count) = (vec![], i64::MAX, 0); @@ -47,7 +52,7 @@ impl UserCountChart { } let datapoints_len = datapoints.len() as isize; - let min_count = min_count - 10; + let min_count = if truncate { min_count - 10 } else { 0 }; let max_count = max_count + 10; let path = parent.join(format!("{group_name}.svg")); diff --git a/source/cli/run.rs b/source/cli/run.rs index 5329d31..772b7b8 100644 --- a/source/cli/run.rs +++ b/source/cli/run.rs @@ -111,12 +111,13 @@ pub async fn run() -> Result<()> { create_dir_all(&output).await?; for group in &groups { - UserCountChart { + let chart = UserCountChart { groups: GroupDataModel::get_n_most_recent(&db, 31, &group.name) .await?, - } - .render(&output, &group.name, true) - .await?; + }; + + chart.render(&output, &group.name, true, true).await?; + chart.render(&output, &group.name, true, false).await?; GroupTemplate::new(group.description.clone(), &group.name) .await @@ -138,6 +139,13 @@ pub async fn run() -> Result<()> { let path = output.join(&format!("charts/user-count/{}.svg", &group.name)); copy(path, output.join("charts/main-user-count.svg")).await?; + + let path = output.join(&format!( + "charts-untruncated/user-count/{}.svg", + &group.name + )); + copy(path, output.join("charts-untruncated/main-user-count.svg")) + .await?; } } },