Merge pull request #648 from AppFlowy-IO/disable-search-indexing

chore: rename af_workspace settings disable_indexing to disable_search_indexing in database queries
This commit is contained in:
Bartosz Sypytkowski 2024-06-24 11:27:25 +02:00 committed by GitHub
commit 0f9fcf2042
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 36 deletions

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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

View File

@ -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 {