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:
@@ -66,7 +66,63 @@ def list_topics(
|
||||
else:
|
||||
query = query.order_by(sort_col.asc())
|
||||
|
||||
return query.offset(offset).limit(limit).all()
|
||||
topics = query.offset(offset).limit(limit).all()
|
||||
# Enrich with article count and previews
|
||||
from ..models import Article
|
||||
topic_ids = [t.id for t in topics]
|
||||
if topic_ids:
|
||||
article_rows = (
|
||||
db.query(Article.topic_id, Article.platform, Article.title, Article.word_count, Article.status)
|
||||
.filter(Article.topic_id.in_(topic_ids))
|
||||
.all()
|
||||
)
|
||||
articles_by_topic: Dict[str, list] = {}
|
||||
for ar in article_rows:
|
||||
articles_by_topic.setdefault(ar.topic_id, []).append({
|
||||
"platform": ar.platform,
|
||||
"title": ar.title,
|
||||
"word_count": ar.word_count,
|
||||
"status": ar.status,
|
||||
})
|
||||
else:
|
||||
articles_by_topic = {}
|
||||
|
||||
result = []
|
||||
for t in topics:
|
||||
t_dict = {
|
||||
"id": t.id,
|
||||
"field_id": t.field_id,
|
||||
"field_name": t.field_name,
|
||||
"org_id": t.org_id,
|
||||
"title": t.title,
|
||||
"format": t.format,
|
||||
"core_concept": t.core_concept,
|
||||
"audience_pain": t.audience_pain,
|
||||
"unique_angle": t.unique_angle,
|
||||
"priority": t.priority,
|
||||
"priority_score": t.priority_score,
|
||||
"total_score": t.total_score,
|
||||
"status": t.status,
|
||||
"tags": t.tags or [],
|
||||
"custom_data": t.custom_data or {},
|
||||
"scoring_data": t.scoring_data or {},
|
||||
"lock_by": t.lock_by,
|
||||
"lock_at": t.lock_at,
|
||||
"series": t.series,
|
||||
"created_at": t.created_at,
|
||||
"updated_at": t.updated_at,
|
||||
"generated_at": t.generated_at,
|
||||
"reviewed_at": t.reviewed_at,
|
||||
"ready_at": t.ready_at,
|
||||
"published_at": t.published_at,
|
||||
"compliance_score": t.compliance_score,
|
||||
"platform_urls": t.platform_urls or {},
|
||||
"cases": [],
|
||||
"article_count": len(articles_by_topic.get(t.id, [])),
|
||||
"articles": articles_by_topic.get(t.id, []),
|
||||
}
|
||||
result.append(t_dict)
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/stats")
|
||||
|
||||
Reference in New Issue
Block a user