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:
+25
-1
@@ -1,6 +1,30 @@
|
||||
# continuation.md — English Financial News 项目状态
|
||||
|
||||
> 最后更新:2026-07-23
|
||||
> 最后更新:2026-08-04
|
||||
|
||||
---
|
||||
|
||||
## 2026-08-04 会话成果
|
||||
|
||||
### M9:日报结构化入库(HTML → MySQL)
|
||||
|
||||
**背景:** 与 news 项目对齐,日报内容不再产出 HTML / scp 上传 doorcome,改为写入共用 MySQL `myquant` 库(表 `news_report` / `news_event`,`report_type="intl"`)。历史日报(2026-06-16 ~ 2026-08-03,intl 128 份)已由 news 项目解析入库,本次仅做新日报按相同契约入库。
|
||||
|
||||
**改动:**
|
||||
|
||||
| 文件 | 改动内容 |
|
||||
|------|---------|
|
||||
| `report_db/`(新增) | 复用 news 项目实现:`models.py`(EventRow/ReportData)、`schema.py`(news_report/news_event DDL)、`db.py`(load_db_config/connect/init_schema/save_report/fetch_report/exists_report,loguru 换 logging) |
|
||||
| `scheduler/reporter.py` | 新增 `_build_report_data()`(intl 结构:事件全部 `section="intl"`,`file_name=""` 幂等覆盖,stats 含 pipeline/sentiment/importance/event_types/source_dist);`generate_report()` 返回 `int | None`,收集逻辑不变,末尾 `connect()+save_report()`;HTML 渲染/上传函数保留标 deprecated |
|
||||
| `scheduler/pipeline.py` | `run_step_report` 适配 `report_id` 返回值 |
|
||||
| `app/cli.py` | `report` 命令打印 `report_id` |
|
||||
| `pyproject.toml` | `uv add pymysql`;`report_db/schema.py` 加 E501 per-file-ignore |
|
||||
| `.env.example` / `README.md` | 新增 `NEWS_DB_*` 配置说明(pi5 经内网直连 `192.168.1.10:13306`,password 与 news 项目相同) |
|
||||
| `tests/test_report_db.py`(新增) | 模型默认值 + `_build_report_data` 组装(板块/rank、字段映射、标题截断、stats 快照、`"?"` 归一化) |
|
||||
|
||||
**测试结果:** `uv run pytest` → 174 passed / 2 failed(2 个失败为原有 `test_crawler.py` index.jsonl 路径问题,与本次无关);ruff 改动文件干净(仅剩原有 `_SENTENCE_END` N806)。
|
||||
|
||||
**部署:** 已 rsync 至 pi5(`/home/pi/intlnews`),`.env` 写入 NEWS_DB_*,`uv sync` 安装 pymysql,真实生成日报并回读 DB 验证(详见下方)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user