fix(database): 修复使用不存在的 get_all_by/get_all 方法

问题:
- CRUDBase 没有 get_all() 和 get_all_by() 方法
- 导致运行时错误: greenlet_spawn has not been called

修复:
- get_all()  get_multi(limit=100000)
- get_all_by(chat_id=x)  get_multi(chat_id=x, limit=10000)

影响文件:
- expression_learner.py: 2处修复
- person_info.py: 1处修复
- chat_stream.py: 1处修复
This commit is contained in:
Windpicker-owo
2025-11-01 16:17:39 +08:00
parent 52c3f81175
commit 19ed3fd048
3 changed files with 4 additions and 4 deletions

View File

@@ -251,7 +251,7 @@ class ExpressionLearner:
# 使用CRUD查询 # 使用CRUD查询
crud = CRUDBase(Expression) crud = CRUDBase(Expression)
all_expressions = await crud.get_all_by(chat_id=chat_id) all_expressions = await crud.get_multi(chat_id=chat_id, limit=10000)
for expr in all_expressions: for expr in all_expressions:
# 确保create_date存在如果不存在则使用last_active_time # 确保create_date存在如果不存在则使用last_active_time
@@ -284,7 +284,7 @@ class ExpressionLearner:
try: try:
# 使用CRUD查询所有表达方式 # 使用CRUD查询所有表达方式
crud = CRUDBase(Expression) crud = CRUDBase(Expression)
all_expressions = await crud.get_all() all_expressions = await crud.get_multi(limit=100000) # 获取所有表达方式
updated_count = 0 updated_count = 0
deleted_count = 0 deleted_count = 0

View File

@@ -704,7 +704,7 @@ class ChatManager:
loaded_streams_data = [] loaded_streams_data = []
# 使用CRUD批量查询 # 使用CRUD批量查询
crud = CRUDBase(ChatStreams) crud = CRUDBase(ChatStreams)
all_streams = await crud.get_all() all_streams = await crud.get_multi(limit=100000) # 获取所有聊天流
for model_instance in all_streams: for model_instance in all_streams:
user_info_data = { user_info_data = {

View File

@@ -643,7 +643,7 @@ class PersonInfoManager:
try: try:
# 使用CRUD获取所有记录 # 使用CRUD获取所有记录
crud = CRUDBase(PersonInfo) crud = CRUDBase(PersonInfo)
all_records = await crud.get_all() all_records = await crud.get_multi(limit=100000) # 获取所有记录
for record in all_records: for record in all_records:
value = getattr(record, f_name, None) value = getattr(record, f_name, None)
if value is not None and way(value): if value is not None and way(value):