fix(memory): allow end user id keyword search

- Match keyword against end_user_id even when other_name exists
- Keep Neo4j and RAG end user list search behavior consistent
This commit is contained in:
miao
2026-04-29 16:38:11 +08:00
parent c57490a063
commit 89bdb9f4b5
2 changed files with 4 additions and 17 deletions

View File

@@ -353,7 +353,7 @@ class ForgettingScheduler:
return results[0]['total']
return 0
async def _sync_memory_count_to_mysql(
async def _sync_memory_count_to_db(
self,
end_user_id: Optional[str] = None,
) -> None:

View File

@@ -130,20 +130,13 @@ def get_workspace_end_users_paginated(
if keyword:
keyword_pattern = f"%{keyword}%"
# other_name 匹配始终生效id 匹配仅对 other_name 为空的记录生效
base_query = base_query.filter(
or_(
EndUserModel.other_name.ilike(keyword_pattern),
and_(
or_(
EndUserModel.other_name.is_(None),
EndUserModel.other_name == "",
),
cast(EndUserModel.id, String).ilike(keyword_pattern),
),
cast(EndUserModel.id, String).ilike(keyword_pattern),
)
)
business_logger.info(f"应用模糊搜索: keyword={keyword}(匹配 other_nameother_name 为空时匹配 id")
business_logger.info(f"应用模糊搜索: keyword={keyword}(匹配 other_name id")
# 获取总记录数
total = base_query.count()
@@ -232,13 +225,7 @@ def get_workspace_end_users_paginated_rag(
base_query = base_query.filter(
or_(
EndUserModel.other_name.ilike(keyword_pattern),
and_(
or_(
EndUserModel.other_name.is_(None),
EndUserModel.other_name == "",
),
cast(EndUserModel.id, String).ilike(keyword_pattern),
),
cast(EndUserModel.id, String).ilike(keyword_pattern),
)
)