Fix waiting function

This commit is contained in:
Elnu 2025-03-28 15:03:54 -07:00
parent 0040dcf6df
commit 6ff3db09c5

View file

@ -7,7 +7,7 @@ use rocket::{
fs::{relative, FileServer}, Ignite, Rocket fs::{relative, FileServer}, Ignite, Rocket
}; };
use rocket_dyn_templates::{tera, Template}; use rocket_dyn_templates::{tera, Template};
use tokio::time; use tokio::time::sleep;
use std::{collections::HashMap, env, time::Duration}; use std::{collections::HashMap, env, time::Duration};
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -63,9 +63,9 @@ async fn main() {
}, },
None => { None => {
tokio::task::spawn(async { tokio::task::spawn(async {
let mut interval = time::interval(Duration::from_millis(60 * 60 * 1000)); // every hour const INTERVAL: Duration = Duration::from_millis(60 * 60 * 1000); // every hour
loop { loop {
interval.tick().await; sleep(INTERVAL).await;
if let Err(err) = DATABASE.refresh_users(&HTTP).await { if let Err(err) = DATABASE.refresh_users(&HTTP).await {
error!("{:?}", err); error!("{:?}", err);
} }