From b46289bb1eb144b0612aea5048b03ff6c3dda76d Mon Sep 17 00:00:00 2001 From: penghanyuan Date: Sat, 14 Feb 2026 11:16:09 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=AB=A0=E8=8A=82?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BB=85=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=B4=BB=E8=B7=83=E7=AB=A0=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改章节查询语句,确保只查找标记为活跃的章节,避免更新已清除的章节。 - 相关注释更新以反映新的逻辑,提升代码可读性。 --- api/tasks/memoir_tasks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/tasks/memoir_tasks.py b/api/tasks/memoir_tasks.py index d795ab3..a5bb63d 100644 --- a/api/tasks/memoir_tasks.py +++ b/api/tasks/memoir_tasks.py @@ -212,10 +212,11 @@ def process_memoir_segments(self, user_id: str, segment_ids: List[str]): combined_text = "\n\n".join(segment_texts) source_ids = [seg.id for seg in stage_segments] - # 查找或创建章节 + # 查找 active 章节(被清除的章节不继续更新,而是创建新的) stmt_chapter = select(Chapter).where( Chapter.user_id == user_id, Chapter.category == stage, + Chapter.is_active == True, ) result_chapter = db.execute(stmt_chapter) chapter = result_chapter.scalar_one_or_none() @@ -340,10 +341,11 @@ def generate_chapter_content(self, user_id: str, stage: str, new_content: str): try: llm = llm_service.get_llm() - # 查找章节 + # 查找 active 章节(被清除的章节不继续更新,而是创建新的) stmt = select(Chapter).where( Chapter.user_id == user_id, Chapter.category == stage, + Chapter.is_active == True, ) result = db.execute(stmt) chapter = result.scalar_one_or_none()