diff --git a/.sqlx/query-ff77d2a038e3130bf57d055e26b37ea61f37167a21cefb4b8480bd511ce2a878.json b/.sqlx/query-26f293af01281f6f4a99fd69d3a4acc1a556dd3628873fa3ce3e8eaa18ccda1b.json similarity index 60% rename from .sqlx/query-ff77d2a038e3130bf57d055e26b37ea61f37167a21cefb4b8480bd511ce2a878.json rename to .sqlx/query-26f293af01281f6f4a99fd69d3a4acc1a556dd3628873fa3ce3e8eaa18ccda1b.json index 63a9857f..d6bba3f1 100644 --- a/.sqlx/query-ff77d2a038e3130bf57d055e26b37ea61f37167a21cefb4b8480bd511ce2a878.json +++ b/.sqlx/query-26f293af01281f6f4a99fd69d3a4acc1a556dd3628873fa3ce3e8eaa18ccda1b.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n select c.workspace_id, c.oid, c.partition_key\n from af_collab c\n where not exists (\n select 1\n from af_collab_embeddings em\n where em.oid = c.oid and em.partition_key = 0)", + "query": "\n select c.workspace_id, c.oid, c.partition_key\n from af_collab c\n join af_workspace w on c.workspace_id = w.workspace_id\n where not coalesce(w.settings['disable_search_indexding']::boolean, false)\n and not exists (\n select 1\n from af_collab_embeddings em\n where em.oid = c.oid and em.partition_key = 0)", "describe": { "columns": [ { @@ -28,5 +28,5 @@ false ] }, - "hash": "ff77d2a038e3130bf57d055e26b37ea61f37167a21cefb4b8480bd511ce2a878" + "hash": "26f293af01281f6f4a99fd69d3a4acc1a556dd3628873fa3ce3e8eaa18ccda1b" } diff --git a/.sqlx/query-7c0d6de28d557d83cf94faceef1216ea932ffe1bf29f8ed3dafeb6ddeea437fb.json b/.sqlx/query-7c0d6de28d557d83cf94faceef1216ea932ffe1bf29f8ed3dafeb6ddeea437fb.json new file mode 100644 index 00000000..c2baf5a5 --- /dev/null +++ b/.sqlx/query-7c0d6de28d557d83cf94faceef1216ea932ffe1bf29f8ed3dafeb6ddeea437fb.json @@ -0,0 +1,28 @@ +{ + "db_name": "PostgreSQL", + "query": "\nSELECT\n w.settings['disable_search_indexing']::boolean as disable_search_indexing,\n CASE\n WHEN w.settings['disable_search_indexing']::boolean THEN\n FALSE\n ELSE\n EXISTS (SELECT 1 FROM af_collab_embeddings m WHERE m.partition_key = c.partition_key AND m.oid = c.oid)\n END as has_index\nFROM af_collab c\nJOIN af_workspace w ON c.workspace_id = w.workspace_id\nWHERE c.oid = $1", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "disable_search_indexing", + "type_info": "Bool" + }, + { + "ordinal": 1, + "name": "has_index", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + null, + null + ] + }, + "hash": "7c0d6de28d557d83cf94faceef1216ea932ffe1bf29f8ed3dafeb6ddeea437fb" +} diff --git a/.sqlx/query-e6105ace4f5b9b71a7edc30f80c6f06877f5a8c49830a4126ee61f7c2e9db03a.json b/.sqlx/query-e6105ace4f5b9b71a7edc30f80c6f06877f5a8c49830a4126ee61f7c2e9db03a.json deleted file mode 100644 index 1b165399..00000000 --- a/.sqlx/query-e6105ace4f5b9b71a7edc30f80c6f06877f5a8c49830a4126ee61f7c2e9db03a.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\nSELECT\n w.settings['disable_indexing']::boolean as disable_indexing,\n CASE\n WHEN w.settings['disable_indexing']::boolean THEN\n FALSE\n ELSE\n EXISTS (SELECT 1 FROM af_collab_embeddings m WHERE m.partition_key = c.partition_key AND m.oid = c.oid)\n END as has_index\nFROM af_collab c\nJOIN af_workspace w ON c.workspace_id = w.workspace_id\nWHERE c.oid = $1", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "disable_indexing", - "type_info": "Bool" - }, - { - "ordinal": 1, - "name": "has_index", - "type_info": "Bool" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - null, - null - ] - }, - "hash": "e6105ace4f5b9b71a7edc30f80c6f06877f5a8c49830a4126ee61f7c2e9db03a" -} diff --git a/libs/database/src/index/collab_embeddings_ops.rs b/libs/database/src/index/collab_embeddings_ops.rs index f1509974..a96b5ca0 100644 --- a/libs/database/src/index/collab_embeddings_ops.rs +++ b/libs/database/src/index/collab_embeddings_ops.rs @@ -14,9 +14,9 @@ pub async fn get_index_status( let result = sqlx::query!( r#" SELECT - w.settings['disable_indexing']::boolean as disable_indexing, + w.settings['disable_search_indexing']::boolean as disable_search_indexing, CASE - WHEN w.settings['disable_indexing']::boolean THEN + WHEN w.settings['disable_search_indexing']::boolean THEN FALSE ELSE EXISTS (SELECT 1 FROM af_collab_embeddings m WHERE m.partition_key = c.partition_key AND m.oid = c.oid) @@ -28,7 +28,7 @@ WHERE c.oid = $1"#, ) .fetch_one(tx.deref_mut()) .await?; - if result.disable_indexing.unwrap_or(false) { + if result.disable_search_indexing.unwrap_or(false) { return Ok(None); } Ok(Some(result.has_index.unwrap_or(false))) @@ -94,7 +94,9 @@ where r#" select c.workspace_id, c.oid, c.partition_key from af_collab c - where not exists ( + join af_workspace w on c.workspace_id = w.workspace_id + where not coalesce(w.settings['disable_search_indexding']::boolean, false) + and not exists ( select 1 from af_collab_embeddings em where em.oid = c.oid and em.partition_key = 0)"# // atm. get only documents diff --git a/src/biz/workspace/ops.rs b/src/biz/workspace/ops.rs index 5d9ad694..16bbeae6 100644 --- a/src/biz/workspace/ops.rs +++ b/src/biz/workspace/ops.rs @@ -534,8 +534,8 @@ pub async fn update_workspace_settings( let mut setting = select_workspace_settings(tx.deref_mut(), workspace_id) .await? .unwrap_or_default(); - if let Some(disable_indexing) = change.disable_search_indexing { - setting.disable_search_indexing = disable_indexing; + if let Some(disable_search_indexing) = change.disable_search_indexing { + setting.disable_search_indexing = disable_search_indexing; } if let Some(ai_model) = change.ai_model {