diff --git a/platform/backend/app/api/tasks.py b/platform/backend/app/api/tasks.py index 2515a74..26ed53f 100644 --- a/platform/backend/app/api/tasks.py +++ b/platform/backend/app/api/tasks.py @@ -267,17 +267,12 @@ 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) - by_source_clean[label] = by_source_clean.get(label, 0) + 1 + 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]] except Exception: