From 4e10cc95d324089fcb8cf7500f8fa57286f79c9a Mon Sep 17 00:00:00 2001 From: Yuzhiran Dev Date: Thu, 21 May 2026 10:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=20tasks.py=20=E6=AD=BB?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/backend/app/api/tasks.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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: