fix(scripts): backfill_body 也回填翻译过但 body 短的文章(让 worker 重译)
This commit is contained in:
@@ -52,15 +52,10 @@ async def backfill(
|
||||
stats = {"scanned": 0, "matched": 0, "updated": 0, "skipped": 0, "failed": 0}
|
||||
|
||||
async with AsyncSessionLocal() as session:
|
||||
# 1) 找短 body 文章
|
||||
stmt = (
|
||||
select(Article)
|
||||
.where((Article.body_text.is_(None)) | (Article.body_text == "") | (Article.translation_status != "ok"))
|
||||
# 简化:只看 body 短的(无论翻译状态)
|
||||
)
|
||||
# 1) 找短 body 文章(不管翻译状态 — 已翻译的也要回填,重置让 worker 用完整 body 重译)
|
||||
stmt = select(Article)
|
||||
if source_slug:
|
||||
stmt = stmt.join(Source, Source.id == Article.source_id).where(Source.slug == source_slug)
|
||||
# 全部扫一次(在内存里过滤 short body,避免 SQL 长度函数复杂)
|
||||
rows = (await session.execute(stmt.order_by(Article.id.desc()))).scalars()
|
||||
all_articles = list(rows)
|
||||
# 过滤 short body
|
||||
|
||||
Reference in New Issue
Block a user