This commit is contained in:
Alexander Petric
2024-11-13 20:27:13 -05:00
parent feaa7e2d0f
commit 75db8e2e8b
3 changed files with 9 additions and 4 deletions
+1
View File
@@ -11034,6 +11034,7 @@ dependencies = [
"chrono",
"chrono-tz 0.10.0",
"cron",
"croner",
"futures-core",
"hex",
"hmac",
+2 -1
View File
@@ -42,4 +42,5 @@ async-recursion.workspace = true
bigdecimal.workspace = true
axum.workspace = true
serde_urlencoded.workspace = true
regex.workspace = true
regex.workspace = true
croner = "2.0.6"
+6 -3
View File
@@ -25,6 +25,7 @@ use windmill_common::{
users::username_to_permissioned_as,
utils::{now_from_db, StripPath},
};
use croner::Cron;
pub async fn push_scheduled_job<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
db: &DB,
@@ -39,7 +40,9 @@ pub async fn push_scheduled_job<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
));
}
let sched = cron::Schedule::from_str(schedule.schedule.as_ref())
let sched = Cron::new(schedule.schedule.as_ref())
.with_seconds_optional()
.parse()
.map_err(|e| error::Error::BadRequest(e.to_string()))?;
let tz = chrono_tz::Tz::from_str(&schedule.timezone)
@@ -65,8 +68,8 @@ pub async fn push_scheduled_job<'c, R: rsmq_async::RsmqConnection + Send + 'c>(
};
let next = sched
.after(&starting_from)
.next()
// `false` means not inclusive of `starting_from`
.find_next_occurrence(&starting_from, false)
.expect("a schedule should have a next event");
// println!("next event ({:?}): {}", tz, next);