From 38d694a2c2b97b869aedee34e52b549a688c225a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luukas=20P=C3=B6rtfors?= Date: Tue, 16 Nov 2021 17:54:41 +0200 Subject: [PATCH] Add UPDATE_INTERVAL that is specified in the .env, solves #4 --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a14e870..a697ec1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,6 +158,11 @@ async fn main() { .parse() .expect("Application id is invalid"); + let update_interval: u32 = env::var("UPDATE_INTERVAL") + .unwrap_or_else(|_| "60".to_string()) // Default to 1 minute + .parse() + .expect("Update interval is invalid"); + let http = Http::new_with_token(&token); let (owner, _bot_id) = match http.get_current_application_info().await { @@ -198,7 +203,7 @@ async fn main() { let database = client.get_db().await; let mut itemhistory = data.write().await.get_mut::().unwrap().clone(); - scheduler.every(1.minute()).run(move || { + scheduler.every(update_interval.second()).run(move || { runtime.block_on(vahti::update_all_vahtis( database.to_owned(), &mut itemhistory,