数据新鲜度校验: 所有模块加上日期/时效检查
1. search_cache.json → 添加 _metadata.updated_at 时间戳 web_search.search_from_cache() 跳过超过36h的旧缓存 防止某查询失败时残留旧数据 2. metrics_feedback.json → collector 检查mtime,超过24h不采用 3. trends.json → 已有 date==TODAY 校验(load_trends) 4. collector_ai_advice → DB每日覆盖,时序安全 creator→topic状态位避免重复生成 optimizer→文章状态位避免重复审查
This commit is contained in:
+12
-7
@@ -398,13 +398,18 @@ class SustainabilityCollector:
|
||||
metrics_file = DATA_DIR / "metrics_feedback.json"
|
||||
if metrics_file.exists():
|
||||
try:
|
||||
feedback = json.loads(metrics_file.read_text(encoding='utf-8'))
|
||||
top_domains = feedback.get("top_domains", [])
|
||||
if top_domains:
|
||||
lines = ["## 历史表现反馈(高互动领域优先", ""]
|
||||
for d, s in top_domains[:3]:
|
||||
lines.append(f"- {d}:平均分 {s}")
|
||||
parts.append("\n".join(lines))
|
||||
mtime = datetime.datetime.fromtimestamp(metrics_file.stat().st_mtime)
|
||||
age = (datetime.datetime.now() - mtime).total_seconds()
|
||||
if age > 86400: # 超过24h的数据不采用
|
||||
logger.debug("metrics_feedback 过时(%.0fh),跳过", age / 3600)
|
||||
else:
|
||||
feedback = json.loads(metrics_file.read_text(encoding='utf-8'))
|
||||
top_domains = feedback.get("top_domains", [])
|
||||
if top_domains:
|
||||
lines = ["## 历史表现反馈(高互动领域优先", ""]
|
||||
for d, s in top_domains[:3]:
|
||||
lines.append(f"- {d}:平均分 {s}")
|
||||
parts.append("\n".join(lines))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user