chore/ 删除无用文件
This commit is contained in:
@@ -151,20 +151,22 @@ class MemoirService:
|
||||
else:
|
||||
if is_new is True:
|
||||
continue
|
||||
all_chapters.append({
|
||||
"id": f"placeholder_{category}",
|
||||
"title": CHAPTER_CATEGORIES[category],
|
||||
"content": "",
|
||||
"order_index": STAGE_TO_ORDER.get(category, 999),
|
||||
"status": "empty",
|
||||
"category": category,
|
||||
"images": [],
|
||||
"cover_image": None,
|
||||
"sections": [],
|
||||
"updated_at": None,
|
||||
"is_new": False,
|
||||
"source_segments": [],
|
||||
})
|
||||
all_chapters.append(
|
||||
{
|
||||
"id": f"placeholder_{category}",
|
||||
"title": CHAPTER_CATEGORIES[category],
|
||||
"content": "",
|
||||
"order_index": STAGE_TO_ORDER.get(category, 999),
|
||||
"status": "empty",
|
||||
"category": category,
|
||||
"images": [],
|
||||
"cover_image": None,
|
||||
"sections": [],
|
||||
"updated_at": None,
|
||||
"is_new": False,
|
||||
"source_segments": [],
|
||||
}
|
||||
)
|
||||
for ch in chapter_by_category.values():
|
||||
await self._cleanup_unavailable_images(ch)
|
||||
all_chapters.append(chapter_to_dict(ch))
|
||||
@@ -231,7 +233,9 @@ class MemoirService:
|
||||
if not ch.category or ch.status == "empty":
|
||||
continue
|
||||
sections = getattr(ch, "sections", None) or []
|
||||
section_image_count = sum(1 for s in sections if getattr(s, "image_id", None))
|
||||
section_image_count = sum(
|
||||
1 for s in sections if getattr(s, "image_id", None)
|
||||
)
|
||||
images = getattr(ch, "images", None) or []
|
||||
cover_rec = next(
|
||||
(m for m in images if getattr(m, "section_id", None) is None),
|
||||
@@ -239,7 +243,10 @@ class MemoirService:
|
||||
)
|
||||
if section_image_count <= 3:
|
||||
continue
|
||||
if cover_rec and (getattr(cover_rec, "status") or "").strip() == "completed":
|
||||
if (
|
||||
cover_rec
|
||||
and (getattr(cover_rec, "status") or "").strip() == "completed"
|
||||
):
|
||||
continue
|
||||
if cover_rec is None:
|
||||
img_settings = MemoirImageSettings.from_env()
|
||||
@@ -281,16 +288,12 @@ class MemoirService:
|
||||
return {"triggered": triggered}
|
||||
|
||||
async def mark_memoir_read(self, user_id: str) -> dict:
|
||||
stmt = select(Chapter).where(
|
||||
Chapter.user_id == user_id, Chapter.is_new == True
|
||||
)
|
||||
stmt = select(Chapter).where(Chapter.user_id == user_id, Chapter.is_new == True)
|
||||
result = await self._db.execute(stmt)
|
||||
for chapter in result.scalars().all():
|
||||
chapter.is_new = False
|
||||
stmt_book = (
|
||||
select(Book)
|
||||
.where(Book.user_id == user_id)
|
||||
.order_by(Book.updated_at.desc())
|
||||
select(Book).where(Book.user_id == user_id).order_by(Book.updated_at.desc())
|
||||
)
|
||||
result_book = await self._db.execute(stmt_book)
|
||||
book = result_book.scalar_one_or_none()
|
||||
|
||||
Reference in New Issue
Block a user