Skip to content

Commit

Permalink
fixed stupid mistake so now the web request is actually done at 12:02am
Browse files Browse the repository at this point in the history
  • Loading branch information
ana_rchy committed May 31, 2024
1 parent 520cd6f commit 385244a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ pub async fn init_jobs(
let sched_closure = sched.clone();
let sunset_time = shared_data.sunset_time.clone();

let new_sunset_time = web::get_sunset_time().await.unwrap();

let job = JobBuilder::new()
.with_timezone(chrono_tz::Europe::Dublin)
.with_cron_job_type()
Expand All @@ -116,14 +114,15 @@ pub async fn init_jobs(
let evening_bag = evening_bag.clone();

Box::pin(async move {
{ *sunset_time.lock().unwrap() = new_sunset_time; }
let new_sunset_time = web::get_sunset_time().await.unwrap();

let id = { *sunset_job_id.lock().unwrap() };
let job = create_sunset_job(http, GENERAL_CHANNEL_ID, new_sunset_time, evening_bag.clone()).await;

_ = sched.remove(&id).await;
let new_id = sched.add(job).await.unwrap();

{ *sunset_time.lock().unwrap() = new_sunset_time; }
{ *sunset_job_id.lock().unwrap() = new_id; }
})
}))
Expand Down

0 comments on commit 385244a

Please sign in to comment.