Fix get datasets owner retrieve the whole dataset (#17370)

This commit is contained in:
Wang Qi
2026-07-27 10:24:13 +08:00
committed by GitHub
parent f53518c110
commit 53afc32349
12 changed files with 137 additions and 4 deletions

View File

@@ -501,6 +501,21 @@ class KnowledgebaseService(CommonService):
return list(kbs.dicts()), total
@classmethod
@DB.connection_context()
def get_owner_filter(cls, joined_tenant_ids, user_id):
owners = (
cls.model.select(
cls.model.tenant_id.alias("id"),
User.nickname.alias("label"),
fn.COUNT(cls.model.id).alias("count"),
)
.join(User, on=(cls.model.tenant_id == User.id))
.where(cls._visibility_and_status_filter(joined_tenant_ids, user_id))
.group_by(cls.model.tenant_id, User.nickname)
)
return list(owners.dicts())
@classmethod
@DB.connection_context()
def accessible(cls, kb_id, user_id):