清理 tasks.py 死代码

This commit is contained in:
Yuzhiran Dev
2026-05-21 10:21:45 +08:00
parent 9178f436b2
commit 4e10cc95d3
+1 -6
View File
@@ -267,16 +267,11 @@ def get_module_detail(module_id: str, db: Session = Depends(get_db), current_use
outputs["采集日期"] = data.get("date", "")
outputs["更新时间"] = data.get("updated_at", "")
outputs["热点总数"] = len(trends)
by_source = {}
for t in trends:
s = t.get("source", "unknown")
by_source.setdefault({"weibo":"微博","zhihu":"知乎","baidu":"百度","llm":"LLM"}.get(s, s), 0)
by_source[[k for k,v in {"weibo":"微博","zhihu":"知乎","baidu":"百度","llm":"LLM"}.items() if v==s or k==s][0] if s in ("weibo","zhihu","baidu","llm") else s] += 1
# count by source properly
by_source_clean = {}
for t in trends:
s = t.get("source", "")
label = {"weibo":"微博","zhihu":"知乎","baidu":"百度","llm":"LLM生成"}.get(s, s)
if label:
by_source_clean[label] = by_source_clean.get(label, 0) + 1
outputs["来源分布"] = by_source_clean
outputs["热点列表"] = [{"topic": t.get("topic",""), "domain": t.get("domain",""), "platform": t.get("platform",""), "source": {"weibo":"微博","zhihu":"知乎","baidu":"百度","llm":"LLM"}.get(t.get("source",""),"")} for t in trends[:20]]