charts code refactoring

This commit is contained in:
aglkm
2024-09-24 13:30:08 +03:00
parent 3a08d82902
commit 5d25108125
3 changed files with 12 additions and 13 deletions

View File

@@ -24,15 +24,17 @@ pub async fn run(dash: Arc<Mutex<Dashboard>>, blocks: Arc<Mutex<Vec<Block>>>,
let mut stats = stats.lock().unwrap();
// Push new date and restart timer every 24H
if stats.timing == 0 || stats.timing >= 86400 {
// Every day push new date into the vector
if let Some(v) = stats.date.last() {
// If new day, pushing date into the vector
if *v != format!("\"{}\"", Utc::now().format("%d-%m-%Y")) {
stats.date.push(format!("\"{}\"", Utc::now().format("%d-%m-%Y")));
}
} else {
// Vector is empty, pushing current date
stats.date.push(format!("\"{}\"", Utc::now().format("%d-%m-%Y")));
stats.timing = 0;
}
// Increasing timing by 15 seconds (data update period)
stats.timing = stats.timing + 15;
Ok(())
}