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:
@@ -353,7 +353,7 @@ class ForgettingScheduler:
|
|||||||
return results[0]['total']
|
return results[0]['total']
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
async def _sync_memory_count_to_mysql(
|
async def _sync_memory_count_to_db(
|
||||||
self,
|
self,
|
||||||
end_user_id: Optional[str] = None,
|
end_user_id: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@@ -130,20 +130,13 @@ def get_workspace_end_users_paginated(
|
|||||||
|
|
||||||
if keyword:
|
if keyword:
|
||||||
keyword_pattern = f"%{keyword}%"
|
keyword_pattern = f"%{keyword}%"
|
||||||
# other_name 匹配始终生效;id 匹配仅对 other_name 为空的记录生效
|
|
||||||
base_query = base_query.filter(
|
base_query = base_query.filter(
|
||||||
or_(
|
or_(
|
||||||
EndUserModel.other_name.ilike(keyword_pattern),
|
EndUserModel.other_name.ilike(keyword_pattern),
|
||||||
and_(
|
cast(EndUserModel.id, String).ilike(keyword_pattern),
|
||||||
or_(
|
|
||||||
EndUserModel.other_name.is_(None),
|
|
||||||
EndUserModel.other_name == "",
|
|
||||||
),
|
|
||||||
cast(EndUserModel.id, String).ilike(keyword_pattern),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
business_logger.info(f"应用模糊搜索: keyword={keyword}(匹配 other_name;other_name 为空时匹配 id)")
|
business_logger.info(f"应用模糊搜索: keyword={keyword}(匹配 other_name 或 id)")
|
||||||
|
|
||||||
# 获取总记录数
|
# 获取总记录数
|
||||||
total = base_query.count()
|
total = base_query.count()
|
||||||
@@ -232,13 +225,7 @@ def get_workspace_end_users_paginated_rag(
|
|||||||
base_query = base_query.filter(
|
base_query = base_query.filter(
|
||||||
or_(
|
or_(
|
||||||
EndUserModel.other_name.ilike(keyword_pattern),
|
EndUserModel.other_name.ilike(keyword_pattern),
|
||||||
and_(
|
cast(EndUserModel.id, String).ilike(keyword_pattern),
|
||||||
or_(
|
|
||||||
EndUserModel.other_name.is_(None),
|
|
||||||
EndUserModel.other_name == "",
|
|
||||||
),
|
|
||||||
cast(EndUserModel.id, String).ilike(keyword_pattern),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user