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}
|
stats = {"scanned": 0, "matched": 0, "updated": 0, "skipped": 0, "failed": 0}
|
||||||
|
|
||||||
async with AsyncSessionLocal() as session:
|
async with AsyncSessionLocal() as session:
|
||||||
# 1) 找短 body 文章
|
# 1) 找短 body 文章(不管翻译状态 — 已翻译的也要回填,重置让 worker 用完整 body 重译)
|
||||||
stmt = (
|
stmt = select(Article)
|
||||||
select(Article)
|
|
||||||
.where((Article.body_text.is_(None)) | (Article.body_text == "") | (Article.translation_status != "ok"))
|
|
||||||
# 简化:只看 body 短的(无论翻译状态)
|
|
||||||
)
|
|
||||||
if source_slug:
|
if source_slug:
|
||||||
stmt = stmt.join(Source, Source.id == Article.source_id).where(Source.slug == 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()
|
rows = (await session.execute(stmt.order_by(Article.id.desc()))).scalars()
|
||||||
all_articles = list(rows)
|
all_articles = list(rows)
|
||||||
# 过滤 short body
|
# 过滤 short body
|
||||||
|
|||||||
Reference in New Issue
Block a user