diff --git a/consumer/src/indexer/db.rs b/consumer/src/indexer/db.rs index b875f7f0..6e3f6696 100644 --- a/consumer/src/indexer/db.rs +++ b/consumer/src/indexer/db.rs @@ -106,12 +106,16 @@ pub async fn insert_follow( .await } -pub async fn delete_follow(conn: &mut AsyncPgConnection, at_uri: &str) -> QueryResult { +pub async fn delete_follow( + conn: &mut AsyncPgConnection, + at_uri: &str, +) -> QueryResult> { diesel::delete(schema::follows::table) .filter(schema::follows::at_uri.eq(at_uri)) .returning(schema::follows::subject) .get_result(conn) .await + .optional() } pub async fn update_follow_stats( diff --git a/consumer/src/indexer/mod.rs b/consumer/src/indexer/mod.rs index 9cb9a835..cc9dccc5 100644 --- a/consumer/src/indexer/mod.rs +++ b/consumer/src/indexer/mod.rs @@ -178,9 +178,12 @@ async fn process_op( match collection { CollectionType::BskyBlock => db::delete_block(conn, &full_path).await?, CollectionType::BskyFollow => { - let subject = db::delete_follow(conn, &full_path).await?; - db::update_follow_stats(conn, &[repo, &subject]).await? - }, + if let Some(subject) = db::delete_follow(conn, &full_path).await? { + db::update_follow_stats(conn, &[repo, &subject]).await? + } else { + 0 + } + } _ => unreachable!(), }; } else {