feat: M9 日报结构化入库(HTML 改为写入 MySQL news_report/news_event,report_type=intl)

- 新增 report_db/ 包(models/schema/db,复用 news 项目实现,幂等 upsert)
- reporter.py: _build_report_data + generate_report 写库返回 report_id
- pipeline/cli 适配 report_id 返回值;HTML 渲染/上传保留 deprecated
- 新增 tests/test_report_db.py;.env.example 增加 NEWS_DB_* 配置
- 已部署 pi5 并验证:真实生成 report_id=184(12 事件)+ 幂等覆盖
This commit is contained in:
2026-08-04 11:09:17 +08:00
parent e1ec5f836d
commit d4a55bcaaa
14 changed files with 669 additions and 69 deletions
+7 -6
View File
@@ -3,8 +3,8 @@
import logging
import sys
from dotenv import load_dotenv
import typer
from dotenv import load_dotenv
# 加载 .env 环境变量(必须在所有模块导入之前)
load_dotenv()
@@ -44,6 +44,7 @@ def crawl(
):
"""M1: 抓取英文财经新闻(部署海外)"""
import os
from crawler.orchestrator import run_crawl_sync
if profile:
@@ -196,15 +197,15 @@ def search(
@app.command()
def report():
"""M7: 日报生成"""
"""M7: 日报生成(结构化入库,不再产出 HTML"""
from scheduler.reporter import generate_report
try:
path = generate_report()
if path:
typer.echo(f"\n✅ 日报已生成: {path}")
report_id = generate_report()
if report_id is not None:
typer.echo(f"\n✅ 日报已入库: report_id={report_id}")
else:
typer.echo("⚠️ 无数据,跳过日报生成")
typer.echo("⚠️ 无数据或入库失败,跳过日报生成")
except Exception as e:
logger.exception("日报生成失败")
typer.echo(f"❌ 日报生成出错: {e}", err=True)