Cleaned up project structure
Some checks failed
Rust / build_and_test (push) Failing after 1m16s

This commit is contained in:
Lukas Wölfer
2026-01-17 21:58:29 +01:00
parent 7baff3a50c
commit 681cc0f59d
17 changed files with 253 additions and 162 deletions

View File

@@ -5,32 +5,38 @@ use rand::seq::SliceRandom as _;
use tokio::time::sleep;
use crate::{watchdog::generate_page, wikiinfo::index_wsdc_ids};
use crate::fetching::DynWsdcFetcher;
pub async fn update_wsdc(bot: Bot) -> ! {
pub async fn update_wsdc(bot: Bot, fetcher: DynWsdcFetcher) -> ! {
loop {
update_all_teachers(&bot).await;
update_all_teachers(&bot, fetcher.clone()).await;
}
}
/// Updates all teachers once
async fn update_all_teachers(bot: &Bot) {
let mut l = index_wsdc_ids(bot).await;
async fn update_all_teachers(bot: &Bot, fetcher: DynWsdcFetcher) {
let mut l = index_wsdc_ids(bot, fetcher.clone()).await;
l.shuffle(&mut rand::rng());
tracing::info!("We have to update {} pages", l.len());
let wait_duration = Duration::from_hours(6);
for (index, page) in l {
process_page(wait_duration, index, page).await;
process_page(wait_duration, index, page, fetcher.clone()).await;
}
tracing::info!("Updates all pages");
}
#[tracing::instrument(skip(page, wait_duration))]
async fn process_page(wait_duration: Duration, index: u32, page: mwbot::Page) {
#[tracing::instrument(skip(page, wait_duration, fetcher))]
async fn process_page(
wait_duration: Duration,
index: u32,
page: mwbot::Page,
fetcher: DynWsdcFetcher,
) {
tracing::info!("Next up");
sleep(wait_duration).await;
match generate_page(index, page).await {
match generate_page(index, page, fetcher).await {
Ok(()) => (),
Err(err) => {
tracing::error!("Error updating: {err}");