From 2fd14746477b45747922180f05406aeb840ed248 Mon Sep 17 00:00:00 2001 From: Aleksei Voronov Date: Thu, 21 Sep 2023 13:25:36 +0200 Subject: [PATCH] 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 --- src/processes/profile_classifier.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/processes/profile_classifier.rs b/src/processes/profile_classifier.rs index 058861e..04e810f 100644 --- a/src/processes/profile_classifier.rs +++ b/src/processes/profile_classifier.rs @@ -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(()) }