Skip to content

Commit

Permalink
Add UPDATE_INTERVAL that is specified in the .env, solves #4
Browse files Browse the repository at this point in the history
  • Loading branch information
lajp committed Nov 16, 2021
1 parent 37e0c99 commit 38d694a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -198,7 +203,7 @@ async fn main() {
let database = client.get_db().await;
let mut itemhistory = data.write().await.get_mut::<ItemHistory>().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,
Expand Down

0 comments on commit 38d694a

Please sign in to comment.