From 89bdb9f4b54dfec9f59fcf934f2e8b88a730b8a8 Mon Sep 17 00:00:00 2001 From: miao <1468212639@qq.com> Date: Wed, 29 Apr 2026 16:38:11 +0800 Subject: [PATCH] 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 --- .../forgetting_engine/forgetting_scheduler.py | 2 +- api/app/services/memory_dashboard_service.py | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/api/app/core/memory/storage_services/forgetting_engine/forgetting_scheduler.py b/api/app/core/memory/storage_services/forgetting_engine/forgetting_scheduler.py index acd436c7..8432c4dd 100644 --- a/api/app/core/memory/storage_services/forgetting_engine/forgetting_scheduler.py +++ b/api/app/core/memory/storage_services/forgetting_engine/forgetting_scheduler.py @@ -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: diff --git a/api/app/services/memory_dashboard_service.py b/api/app/services/memory_dashboard_service.py index 6ce793a1..64874caf 100644 --- a/api/app/services/memory_dashboard_service.py +++ b/api/app/services/memory_dashboard_service.py @@ -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_name;other_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), ) )