From 58def560b80b2044beea9747fbabf3282983a44c Mon Sep 17 00:00:00 2001 From: Jurriaan Pruis Date: Wed, 5 Jun 2024 21:16:26 +0200 Subject: [PATCH] run cargo fmt --- src/util/plot.rs | 15 ++++++++------- src/web_interface.rs | 24 +++++++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/util/plot.rs b/src/util/plot.rs index 875de2a..98abfaf 100644 --- a/src/util/plot.rs +++ b/src/util/plot.rs @@ -25,18 +25,19 @@ pub fn plot_timeseries_svg( .y_label_area_size(30) .build_cartesian_2d(first_entry.0..last_entry.0, min_y..max_y)?; - let mut mesh = chart - .configure_mesh(); + let mut mesh = chart.configure_mesh(); - if last_entry.0 - first_entry.0 < Duration::hours(48) && Utc::now() - last_entry.0.to_utc() < Duration::hours(24) { + if last_entry.0 - first_entry.0 < Duration::hours(48) + && Utc::now() - last_entry.0.to_utc() < Duration::hours(24) + { mesh.x_label_formatter(&|x| format!("{:02}:{:02}", x.hour(), x.minute())) } else { &mut mesh } - .y_labels(5) - .x_labels(4) - .disable_mesh() - .draw()?; + .y_labels(5) + .x_labels(4) + .disable_mesh() + .draw()?; chart .draw_series(LineSeries::new(entries, &RED))? diff --git a/src/web_interface.rs b/src/web_interface.rs index 6481e0d..6ffd72f 100644 --- a/src/web_interface.rs +++ b/src/web_interface.rs @@ -600,25 +600,35 @@ async fn node_details( .await .map_err(DatabaseError)?; - let max_age_minutes : Option = headers.get("x-meshstellar-max-age").map(|x| x.to_str().unwrap_or("all")).and_then(|x| x.parse().ok()); + let max_age_minutes: Option = headers + .get("x-meshstellar-max-age") + .map(|x| x.to_str().unwrap_or("all")) + .and_then(|x| x.parse().ok()); let min_time_nanos = if let Some(max_age) = max_age_minutes { let cur_time = Utc::now().timestamp_nanos_opt().unwrap(); - cur_time - (max_age as i64 * 60_000_000_000) + cur_time - (max_age * 60_000_000_000) } else { 0 }; - let offset_minutes : i32 = headers.get("x-meshstellar-tz-offset").map(|x| x.to_str().unwrap_or("0")).and_then(|x| x.parse().ok()).unwrap_or_default(); - let offset = if offset_minutes.abs() < 24 * 60 { - FixedOffset::west_opt(offset_minutes * 60).unwrap_or_else(|| FixedOffset::west_opt(0).unwrap()) + let offset_minutes: i32 = headers + .get("x-meshstellar-tz-offset") + .map(|x| x.to_str().unwrap_or("0")) + .and_then(|x| x.parse().ok()) + .unwrap_or_default(); + let offset = if offset_minutes.abs() < 24 * 60 { + FixedOffset::west_opt(offset_minutes * 60) + .unwrap_or_else(|| FixedOffset::west_opt(0).unwrap()) } else { FixedOffset::west_opt(0).unwrap() }; Ok(into_response(&NodeDetailsTemplate { node, - plots: create_plots(pool, node_id, min_time_nanos, offset).await.unwrap_or_default(), + plots: create_plots(pool, node_id, min_time_nanos, offset) + .await + .unwrap_or_default(), })) } @@ -642,7 +652,7 @@ async fn create_plots( pool: State, node_id: i64, min_time: i64, - time_zone_offset: FixedOffset + time_zone_offset: FixedOffset, ) -> axum::response::Result> { let mut entries_map : HashMap, f64)>>= sqlx::query!( r#"