This commit is contained in:
Daniel
2026-03-04 16:48:17 +08:00
parent 64f4c438c3
commit 26938449f0
34 changed files with 956 additions and 500 deletions

View File

@@ -8,6 +8,7 @@ from datetime import datetime, timezone
from typing import Callable, Optional, Tuple
from config import DB_PATH, API_BASE
from db_writer import touch_situation_updated_at_path
def _notify_api(api_base: str) -> bool:
@@ -172,15 +173,18 @@ def run_full_pipeline(
except Exception as e:
print(f" [warn] 正文抓取: {e}")
# 4. 映射到前端库字段并更新表
n_panel = write_updates(new_items) if new_items else 0
# 4. 映射到前端库字段并更新表(与去重/AI 使用同一 db path
n_panel = write_updates(new_items, db_path=path) if new_items else 0
if new_items:
_extract_and_merge(new_items, path)
# 5. 通知(有新增时才通知;可选:先执行外部逻辑如 GDELT 回填,再通知
# 4.5 每次运行都刷新 situation.updated_at便于前端显示「最后抓取时间」否则只有新增条目时才更新数据会一直停在旧日期
touch_situation_updated_at_path(db_path=path)
# 5. 通知(每次运行都通知,让 API 重载并广播最新 lastUpdated
if on_notify:
on_notify()
if notify and (n_panel > 0 or n_news > 0):
if notify:
_notify_api(base)
return len(items), n_news, n_panel