diff --git a/src/main.rs b/src/main.rs index 79df212..97c99a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,8 @@ use warp::Filter; #[tokio::main] async fn main() -> anyhow::Result<()> { + let mins_between_runs = 5; + let hours_between_detailed_runs = 12; let last_update = Arc::new(atomic::AtomicI64::new(chrono::Utc::now().timestamp() / 60)); let last_update_clone = Arc::clone(&last_update); @@ -89,12 +91,12 @@ async fn main() -> anyhow::Result<()> { let empty_game_hash: HashMap = HashMap::new(); let mut sessions: HashMap> = HashMap::new(); let mut last_ran_detailed = chrono::Utc::now(); - let mut last_ran = chrono::Utc::now(); + let mut last_ran = chrono::Utc::now() - chrono::Duration::minutes(mins_between_runs); log::info!("Started"); loop { - let run = last_ran.add(chrono::Duration::minutes(10)) >= chrono::Utc::now(); + let run = last_ran.add(chrono::Duration::minutes(mins_between_runs)) <= chrono::Utc::now(); if run { log::info!("Starting new run"); last_ran = chrono::Utc::now(); @@ -201,8 +203,9 @@ async fn main() -> anyhow::Result<()> { } log::info!("battlelog done"); - let run_detailed = - last_ran_detailed.add(chrono::Duration::hours(12)) <= chrono::Utc::now(); + let run_detailed = last_ran_detailed + .add(chrono::Duration::hours(hours_between_detailed_runs)) + <= chrono::Utc::now(); if run_detailed { log::info!("Running grpc detailed"); last_ran_detailed = chrono::Utc::now(); @@ -273,7 +276,7 @@ async fn main() -> anyhow::Result<()> { } else { let ten_mins = last_ran + chrono::Duration::minutes(10); log::info!( - "Waiting {:#?} minutes before running again", + "Waiting {:#?} minutes before next run", (ten_mins - last_ran).num_minutes() ); sleep(Duration::from_secs(30)).await;