Don't crash when unable to classify a profile due to some random problem

Random problems include: deleted profiles.

Also always wait 10 seconds between runs, we don't need to do it so often
This commit is contained in:
Aleksei Voronov 2023-09-21 13:25:36 +02:00
parent 93c4979c71
commit 2fd1474647
1 changed files with 7 additions and 3 deletions

View File

@ -2,7 +2,7 @@ use std::sync::Arc;
use std::time::Duration;
use anyhow::Result;
use log::info;
use log::{error, info};
use crate::services::Bluesky;
use crate::services::Database;
@ -37,14 +37,18 @@ impl ProfileClassifier {
let dids = self.database.fetch_unprocessed_profile_dids().await?;
if dids.is_empty() {
info!("No profiles to process: waiting 10 seconds");
tokio::time::sleep(Duration::from_secs(10)).await;
} else {
info!("Classifying {} new profiles", dids.len());
for did in &dids {
self.fill_in_profile_details(did).await?;
match self.fill_in_profile_details(did).await {
Ok(()) => continue,
Err(e) => error!("Could not classify profile: {:?}", e)
}
}
}
tokio::time::sleep(Duration::from_secs(10)).await;
Ok(())
}