fix: pipeline content tracking + topic article preview

db_helper.py: save_article now calculates and persists word_count
generator.py: run_creator_blocking sets word_count for HTML-imported articles
writer.py: fix title regex stripping content-leading numbers (35岁后→岁后)
trends.py: fix Baidu hot_score str/int type comparison crash
database.py: add missing content_tasks.org_id ALTER TABLE migration
schemas.py + topics.py: topic list API returns article_count + articles[] previews
topics.html: table view and card view show article badges with word counts, clickable to open preview

Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
yuzhiran
2026-06-24 12:31:02 +08:00
parent 57e6e16c11
commit d11d7f4980
9 changed files with 100 additions and 8 deletions
+3
View File
@@ -246,12 +246,14 @@ def save_article(topic_id: str, platform: str, html_content: str, *, title: str
from app.models import Article
article_id = f"{platform}_{topic_id}"
existing = db.query(Article).filter(Article.id == article_id).first()
word_count = len(content) if content else (len(html_content) if html_content else 0)
if existing:
existing.html_content = html_content
if title:
existing.title = title
if content:
existing.content = content
existing.word_count = word_count
else:
article = Article(
id=article_id,
@@ -261,6 +263,7 @@ def save_article(topic_id: str, platform: str, html_content: str, *, title: str
title=title,
content=content,
html_content=html_content,
word_count=word_count,
status="draft",
compliance_score=None
)
+2 -1
View File
@@ -193,7 +193,8 @@ def fetch_baidu_hot() -> List[Dict]:
word = item.get("query", "").strip() or item.get("word", "").strip()
if not word:
continue
hot_score = item.get("hotScore", 0) or item.get("heat", 0)
hot_score_raw = item.get("hotScore", 0) or item.get("heat", 0)
hot_score = int(hot_score_raw) if hot_score_raw else 0
desc = item.get("desc", "")
results.append({
"domain": _guess_domain(word, desc),
+1 -1
View File
@@ -557,7 +557,7 @@ class Writer:
line = line.strip()
if not line:
continue
line = re.sub(r'^\d+[.、)\s]+', '', line)
line = re.sub(r'^\d+[.、)]\s*', '', line)
line = line.strip('*#- \t"\'"''"')
# 跳过思考/建议类输出(如"不如:"、"或者:"、"建议方案"等)
if re.match(r'^(不如|或者|建议|推荐|参考|方案[一二三]|第[一二三]种|以[下是]|标题[一二三]|选项)', line):