mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: Optimize recent problem queries. (#556)
This commit is contained in:
@@ -46,8 +46,9 @@ def list_recent_questions(session: SessionDep, current_user: CurrentUser, dataso
|
||||
ChatRecord.question,
|
||||
func.count(ChatRecord.question).label('question_count')
|
||||
)
|
||||
.join(Chat, ChatRecord.chat_id == Chat.id) # 关联Chat表
|
||||
.filter(
|
||||
ChatRecord.datasource == datasource_id,
|
||||
Chat.datasource == datasource_id, # 使用Chat表的datasource字段
|
||||
ChatRecord.question.isnot(None)
|
||||
)
|
||||
.group_by(ChatRecord.question)
|
||||
@@ -57,7 +58,6 @@ def list_recent_questions(session: SessionDep, current_user: CurrentUser, dataso
|
||||
)
|
||||
return [record[0] for record in chat_records] if chat_records else []
|
||||
|
||||
|
||||
def rename_chat(session: SessionDep, rename_object: RenameChat) -> str:
|
||||
chat = session.get(Chat, rename_object.id)
|
||||
if not chat:
|
||||
|
||||
Reference in New Issue
Block a user