diff --git a/ee/tabby-webserver/src/cron/db/mod.rs b/ee/tabby-webserver/src/cron/db/mod.rs index d2f506252042..5dc1a6664aeb 100644 --- a/ee/tabby-webserver/src/cron/db/mod.rs +++ b/ee/tabby-webserver/src/cron/db/mod.rs @@ -5,7 +5,7 @@ mod gitlab; use std::sync::Arc; -use rand::Rng; + use super::{controller::JobController, every_ten_minutes, every_two_hours}; use crate::schema::{ @@ -21,33 +21,49 @@ pub async fn register_jobs( ) { let cloned_auth = auth.clone(); controller - .register("remove_staled_refresh_token", &every_two_hours(), move || { - let auth = cloned_auth.clone(); - Box::pin(async move { Ok(auth.delete_expired_token().await?) }) - }) + .register( + "remove_staled_refresh_token", + &every_two_hours(), + move || { + let auth = cloned_auth.clone(); + Box::pin(async move { Ok(auth.delete_expired_token().await?) }) + }, + ) .await; let cloned_auth = auth.clone(); controller - .register("remove_staled_password_reset", &every_two_hours(), move || { - let auth = cloned_auth.clone(); - Box::pin(async move { Ok(auth.delete_expired_password_resets().await?) }) - }) + .register( + "remove_staled_password_reset", + &every_two_hours(), + move || { + let auth = cloned_auth.clone(); + Box::pin(async move { Ok(auth.delete_expired_password_resets().await?) }) + }, + ) .await; controller - .register_public("github_repositories", &every_ten_minutes(), move |context| { - let context = context.clone(); - let github = github.clone(); - Box::pin(async move { github::refresh_all_repositories(context, github).await }) - }) + .register_public( + "github_repositories", + &every_ten_minutes(), + move |context| { + let context = context.clone(); + let github = github.clone(); + Box::pin(async move { github::refresh_all_repositories(context, github).await }) + }, + ) .await; controller - .register_public("gitlab_repositories", &every_ten_minutes(), move |context| { - let gitlab = gitlab.clone(); - let context = context.clone(); - Box::pin(async move { gitlab::refresh_all_repositories(context, gitlab).await }) - }) + .register_public( + "gitlab_repositories", + &every_ten_minutes(), + move |context| { + let gitlab = gitlab.clone(); + let context = context.clone(); + Box::pin(async move { gitlab::refresh_all_repositories(context, gitlab).await }) + }, + ) .await; -} \ No newline at end of file +} diff --git a/ee/tabby-webserver/src/cron/mod.rs b/ee/tabby-webserver/src/cron/mod.rs index c9a0f06ede6a..2e28b3c469d0 100644 --- a/ee/tabby-webserver/src/cron/mod.rs +++ b/ee/tabby-webserver/src/cron/mod.rs @@ -34,10 +34,14 @@ pub async fn run_cron( fn every_two_hours() -> String { let mut rng = rand::thread_rng(); - format!("{} {} */2 * * *", rng.gen_range(0..59), rng.gen_range(0..59)) + format!( + "{} {} */2 * * *", + rng.gen_range(0..59), + rng.gen_range(0..59) + ) } fn every_ten_minutes() -> String { let mut rng = rand::thread_rng(); format!("{} */10 * * * *", rng.gen_range(0..59)) -} \ No newline at end of file +}