From 285d97f4a9d60777508a55dadaba063f87c3424f Mon Sep 17 00:00:00 2001 From: Mia Date: Thu, 30 Jan 2025 21:48:56 +0000 Subject: [PATCH] stop trying to return rows we don't have --- consumer/src/indexer/db.rs | 6 +++++- consumer/src/indexer/mod.rs | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) 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 { -- 2.51.2