fix: do not throw errors if indexer found document before workspace was created

This commit is contained in:
Bartosz Sypytkowski 2024-06-25 07:22:38 +02:00
parent 0f9fcf2042
commit 2ff2a77465
2 changed files with 18 additions and 6 deletions

View File

@ -2,7 +2,7 @@ use std::ops::DerefMut;
use collab_entity::CollabType;
use pgvector::Vector;
use sqlx::{Executor, Postgres, Transaction};
use sqlx::{Error, Executor, Postgres, Transaction};
use uuid::Uuid;
use database_entity::dto::AFCollabEmbeddingParams;
@ -27,11 +27,23 @@ WHERE c.oid = $1"#,
oid
)
.fetch_one(tx.deref_mut())
.await?;
if result.disable_search_indexing.unwrap_or(false) {
return Ok(None);
.await;
match result {
Ok(row) => {
if row.disable_search_indexing.unwrap_or(false) {
return Ok(None);
}
Ok(Some(row.has_index.unwrap_or(false)))
},
Err(Error::RowNotFound) => {
tracing::warn!(
"open-collab event for {} arrived before its workspace was created",
oid
);
Ok(Some(false))
},
Err(e) => Err(e),
}
Ok(Some(result.has_index.unwrap_or(false)))
}
pub async fn upsert_collab_embeddings(

View File

@ -240,8 +240,8 @@ impl OpenCollabConsumer {
Err(e) => {
tracing::error!(
"failed to open handle for {}/{}: {}",
object_id,
workspace_id,
object_id,
e
);
},