First working version of creation and update watchdog

This commit is contained in:
Lukas Wölfer
2025-07-24 19:02:10 +02:00
parent 29e85397a7
commit 8172d4c769
10 changed files with 195 additions and 122 deletions

24
src/updater.rs Normal file
View 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}");
}
}
}
}