Feature: GET /datasets to support ids array (#17606)

This commit is contained in:
Wang Qi
2026-07-31 13:23:02 +08:00
committed by GitHub
parent e66cfe1372
commit 0969c04eca
6 changed files with 90 additions and 5 deletions

View File

@@ -463,7 +463,7 @@ class KnowledgebaseService(CommonService):
@classmethod
@DB.connection_context()
def get_list(cls, joined_tenant_ids, user_id, page_number, items_per_page, orderby, desc, id, name, keywords, parser_id=None):
def get_list(cls, joined_tenant_ids, user_id, page_number, items_per_page, orderby, desc, id, name, keywords, parser_id=None, ids=None):
# Get list of knowledge bases with filtering and pagination
# Args:
# joined_tenant_ids: List of tenant IDs
@@ -482,6 +482,8 @@ class KnowledgebaseService(CommonService):
kbs = cls.model.select()
if id:
kbs = kbs.where(cls.model.id == id)
if ids:
kbs = kbs.where(cls.model.id.in_(ids))
if name:
kbs = kbs.where(cls.model.name == name)
if keywords:
@@ -501,6 +503,12 @@ class KnowledgebaseService(CommonService):
return list(kbs.dicts()), total
@classmethod
@DB.connection_context()
def get_accessible_ids(cls, joined_tenant_ids, user_id, ids):
kbs = cls.model.select(cls.model.id).where(cls.model.id.in_(ids), cls._visibility_and_status_filter(joined_tenant_ids, user_id))
return {kb.id for kb in kbs}
@classmethod
@DB.connection_context()
def get_owner_filter(cls, joined_tenant_ids, user_id):