add description
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust_agreagator"
|
name = "rust_agreagator"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
|
description = "Script computing the average of values from a sensor in MySQL database."
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|||||||
@@ -80,17 +80,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn aggregate_values(conn: &mut PooledConn, date: NaiveDate) -> Result<(), Box<dyn std::error::Error>> {
|
fn aggregate_values(conn: &mut PooledConn, date: NaiveDate) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
let average_duration = 15;
|
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 = [
|
let sensors = [
|
||||||
Sensor::new("maison".to_string(), "bureau".to_string(), "co2".to_string()),
|
Sensor::new("maison".to_string(), "bureau".to_string(), "co2".to_string()),
|
||||||
Sensor::new("maison".to_string(), "bureau".to_string(), "tvoc".to_string())
|
Sensor::new("maison".to_string(), "bureau".to_string(), "tvoc".to_string())
|
||||||
];
|
];
|
||||||
|
|
||||||
for sensor in &sensors {
|
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;
|
let mut current_time = start_time;
|
||||||
|
|
||||||
while current_time <= end_time {
|
while current_time <= end_time {
|
||||||
|
|||||||
Reference in New Issue
Block a user