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
+20 -6
View File
@@ -10,7 +10,7 @@
- **M4** 全文英译中 + 投资事件抽取(LLM DeepSeek v4-flash
- **M5** 向量生成(DashScope text-embedding-v31024 维)
- **M6** 双语向量知识库(Qdrant
- **M7** 定时调度(06/12/18/22 + 每日 AI 摘要日报
- **M7** 定时调度(06/12/18/22 + 每日 AI 摘要日报(M9 起结构化写入 MySQL,不再产出 HTML)
- **M8** MCP 服务(Cherry Studio / Claude Code Agent 深度研究)
## 部署架构
@@ -27,7 +27,7 @@
│ ↓ │
│ M5 向量生成 → M6 Qdrant 入库 │
│ ↓ │
│ 日报生成 → rsync 上传 doorcome.cn
│ 日报生成 → 写入 MySQLnews_report
│ ↓ │
│ M8 MCP 服务(研究 Agent
└──────────────────────────────────────┘
@@ -119,7 +119,7 @@ bash scripts/domestic_crawl_8g.sh investinglive
# M2→M6 管道(需先有 raw 数据)
bash scripts/pipeline.sh
# 仅生成日报
# 仅生成日报(写入 MySQL news_report/news_eventreport_type="intl"
uv run en-news report
```
@@ -145,6 +145,20 @@ ls -lt data/reports/
| `.env` | 密钥 / 服务地址(不入 Git) |
| `prompts/` | LLM Prompt 模板(翻译/日报/搜索 Agent |
### 日报入库(M9
日报内容结构化写入与 [news 项目](https://github.com/) 共用的 MySQL `myquant` 库(表 `news_report` / `news_event``report_type="intl"`,同一天重复生成幂等覆盖)。表结构与数据契约见 news 项目 `docs/db_schema.md`
`.env` 需配置(与 news 项目 `.env``NEWS_DB_PASSWORD` 相同):
```env
NEWS_DB_HOST=192.168.1.10 # pi5 经内网直连 pi 上的 autossh 隧道(0.0.0.0:13306 → doorcome.cn:3306
NEWS_DB_PORT=13306
NEWS_DB_USER=myquant
NEWS_DB_PASSWORD=xxx
NEWS_DB_NAME=myquant
```
---
## 数据存储
@@ -156,7 +170,7 @@ data/
├── dedup/ M3 去重指纹库(SQLite
├── translations/{yyyymmdd}/ M4 翻译+事件抽取结果(JSONL)
├── embeddings/{yyyymmdd}/ M5 向量文件(JSONL
├── reports/ M7 日报(HTML
├── reports/ M7 日报(M9 起不再产出 HTML,改存 MySQL
└── vectorstore/ M6 Qdrant 数据
```
@@ -191,9 +205,9 @@ uv run en-news mcp-server
部分网站有强反爬(Cloudflare/DataDome/付费墙),RSS 只返回摘要。全文可尝试 headful 浏览器回退,但成功率取决于代理线路质量。
### 日报上传到哪里?
### 日报存在哪里?
日报自动上传到 `simon@doorcome.cn:/var/www/html/echart/research/`,通过 HTTP 访问
M9 起日报结构化写入 MySQL `myquant` 库:主表 `news_report``report_type="intl"`+ 明细表 `news_event``section="intl"`),数据契约与 [news 项目](https://github.com/) 一致(见其 `docs/db_schema.md`)。历史 HTML 日报(2026-06-16 ~ 2026-08-03)已由 news 项目解析导入。API / 前端读取同一批表
### 如何添加新源?