From 10aa0b18184278ff1987eb636bef890b4b5f5e38 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Mon, 19 Aug 2024 22:56:26 +0200 Subject: [PATCH] add description --- Cargo.toml | 3 ++- src/main.rs | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0597109..97d259a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "rust_agreagator" version = "0.1.0" -edition = "2021" +edition = "2024" +description = "Script computing the average of values from a sensor in MySQL database." [dependencies] chrono = "0.4" diff --git a/src/main.rs b/src/main.rs index 0b3c0d6..ea00f58 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,17 +80,15 @@ fn main() -> Result<(), Box> { } fn aggregate_values(conn: &mut PooledConn, date: NaiveDate) -> Result<(), Box> { - let average_duration = 15; - let start_time = Utc.with_ymd_and_hms(date.year(), date.month(), date.day(), 00, 00, 00).unwrap() - (Duration::minutes(average_duration) / 2); - let end_time = start_time + Duration::days(1); - let sensors = [ Sensor::new("maison".to_string(), "bureau".to_string(), "co2".to_string()), Sensor::new("maison".to_string(), "bureau".to_string(), "tvoc".to_string()) ]; for sensor in &sensors { + let start_time = Utc.with_ymd_and_hms(date.year(), date.month(), date.day(), 00, 00, 00).unwrap() - (Duration::minutes(average_duration) / 2); + let end_time = start_time + Duration::days(1); let mut current_time = start_time; while current_time <= end_time {