First working version of creation and update watchdog
This commit is contained in:
24
src/updater.rs
Normal file
24
src/updater.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use mwbot::Bot;
|
||||
use rand::seq::SliceRandom as _;
|
||||
|
||||
use crate::{watchdog::generate_page, wikiinfo::index_wsdc_ids};
|
||||
|
||||
pub async fn update_wsdc(bot: Bot) -> ! {
|
||||
loop {
|
||||
let mut l = index_wsdc_ids(&bot).await;
|
||||
l.shuffle(&mut rand::rng());
|
||||
tracing::info!("We have to update {} pages", l.len());
|
||||
let wait_duration = Duration::from_secs(6 * 3600);
|
||||
for (index, page) in l {
|
||||
tracing::info!("Next up: {index}");
|
||||
tokio::time::sleep(wait_duration).await;
|
||||
if generate_page(index, page).await {
|
||||
tracing::info!("Updated {index}");
|
||||
} else {
|
||||
tracing::error!("Error updating {index}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user