refactor: update SQL queries to include embedding_model_id and adjust filters for knowledge_id
This commit is contained in:
parent
a34c089b73
commit
ac4bf303f4
@ -308,8 +308,8 @@ class KnowledgeSerializer(serializers.Serializer):
|
|||||||
model=get_dynamics_model({'temp.id': models.CharField()})
|
model=get_dynamics_model({'temp.id': models.CharField()})
|
||||||
).filter(**{'temp.id': self.data.get("knowledge_id")}),
|
).filter(**{'temp.id': self.data.get("knowledge_id")}),
|
||||||
'knowledge_custom_sql': QuerySet(
|
'knowledge_custom_sql': QuerySet(
|
||||||
model=get_dynamics_model({'knowledge.user_id': models.CharField()})
|
model=get_dynamics_model({'knowledge.id': models.CharField()})
|
||||||
).filter(**{'knowledge.user_id': self.data.get("user_id")}),
|
).filter(**{'knowledge.id': self.data.get("knowledge_id")}),
|
||||||
'folder_query_set': QuerySet(KnowledgeFolder)
|
'folder_query_set': QuerySet(KnowledgeFolder)
|
||||||
}
|
}
|
||||||
if not workspace_manage:
|
if not workspace_manage:
|
||||||
|
|||||||
@ -12,6 +12,7 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
|
|||||||
"temp_knowledge".file_size_limit,
|
"temp_knowledge".file_size_limit,
|
||||||
"temp_knowledge".file_count_limit,
|
"temp_knowledge".file_count_limit,
|
||||||
"temp_knowledge"."scope",
|
"temp_knowledge"."scope",
|
||||||
|
"temp_knowledge"."embedding_model_id"::text,
|
||||||
"document_temp"."char_length",
|
"document_temp"."char_length",
|
||||||
CASE
|
CASE
|
||||||
WHEN
|
WHEN
|
||||||
@ -21,9 +22,8 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
|
|||||||
FROM (SELECT knowledge.*
|
FROM (SELECT knowledge.*
|
||||||
FROM knowledge knowledge ${knowledge_custom_sql}
|
FROM knowledge knowledge ${knowledge_custom_sql}
|
||||||
AND id in (select target
|
AND id in (select target
|
||||||
from workspace_user_resource_permission
|
from workspace_user_resource_permission ${workspace_user_resource_permission_query_set}
|
||||||
${workspace_user_resource_permission_query_set}
|
and 'VIEW' = any (permission_list))) temp_knowledge
|
||||||
and 'VIEW' = any (permission_list))) temp_knowledge
|
|
||||||
LEFT JOIN (SELECT "count"("id") AS document_count, "sum"("char_length") "char_length", knowledge_id
|
LEFT JOIN (SELECT "count"("id") AS document_count, "sum"("char_length") "char_length", knowledge_id
|
||||||
FROM "document"
|
FROM "document"
|
||||||
GROUP BY knowledge_id) "document_temp" ON temp_knowledge."id" = "document_temp".knowledge_id
|
GROUP BY knowledge_id) "document_temp" ON temp_knowledge."id" = "document_temp".knowledge_id
|
||||||
@ -47,6 +47,7 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
|
|||||||
0 as file_size_limit,
|
0 as file_size_limit,
|
||||||
0 as file_count_limit,
|
0 as file_count_limit,
|
||||||
'WORKSPACE' as "scope",
|
'WORKSPACE' as "scope",
|
||||||
|
'' as embedding_model_id,
|
||||||
0 as char_length,
|
0 as char_length,
|
||||||
0 as application_mapping_count,
|
0 as application_mapping_count,
|
||||||
0 as document_count
|
0 as document_count
|
||||||
|
|||||||
@ -12,6 +12,7 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
|
|||||||
"temp_knowledge".file_size_limit,
|
"temp_knowledge".file_size_limit,
|
||||||
"temp_knowledge".file_count_limit,
|
"temp_knowledge".file_count_limit,
|
||||||
"temp_knowledge"."scope",
|
"temp_knowledge"."scope",
|
||||||
|
"temp_knowledge"."embedding_model_id"::text,
|
||||||
"document_temp"."char_length",
|
"document_temp"."char_length",
|
||||||
CASE
|
CASE
|
||||||
WHEN
|
WHEN
|
||||||
@ -60,6 +61,7 @@ FROM (SELECT "temp_knowledge".id::text, "temp_knowledge".name,
|
|||||||
0 as file_size_limit,
|
0 as file_size_limit,
|
||||||
0 as file_count_limit,
|
0 as file_count_limit,
|
||||||
'WORKSPACE' as "scope",
|
'WORKSPACE' as "scope",
|
||||||
|
'' as embedding_model_id,
|
||||||
0 as char_length,
|
0 as char_length,
|
||||||
0 as application_mapping_count,
|
0 as application_mapping_count,
|
||||||
0 as document_count
|
0 as document_count
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user