feat(djapi): 新增日报查询 API(news/reports + news/events)及文档

- api/report/ 包:query(连库+SQL)/ views(2 视图)/ serializers(OpenAPI)/ tests(17 单测)
- urls.py 注册 news/reports/、news/events/;settings.py SPECTACULAR 加「日报」tag
- .env.example 补 NEWS_DB_* 占位配置;README/continuation.md 更新
- docs/news_report_api.md 使用手册;CLAUDE*.md 修正 CLI 路径为 finance/ 前缀
This commit is contained in:
2026-08-05 20:51:42 +08:00
parent 22ce3a6aea
commit 6ec198687c
17 changed files with 1275 additions and 21 deletions
+33 -1
View File
@@ -4,6 +4,12 @@
djapi — Django 5.2 金融数据 API 项目,2026-06-17 已部署。
## Checkpoint 记录
| 日期 | 内容 |
|------|------|
| 2026-08-03 | 新增日报查询 API ×2news/reports/ + news/events/),基于 news_report/news_event 表,已部署 doorcome ✅ |
服务器:`simon@doorcome.cn`,路径 `/home/simon/myquant/djapi/`,虚拟环境 `/opt/miniconda/envs/django/`
## 已完成
@@ -56,7 +62,7 @@ djapi — Django 5.2 金融数据 API 项目,2026-06-17 已部署。
| `main_videos.py` | 批量补缺(扫描缺失日期) |
| `mysqlHandle.py` | MySQLDB 重新导出 |
## 所有 API 端点(14 个)
## 所有 API 端点(16 个)
| 端点 | 数据源 | 说明 |
|------|--------|------|
@@ -74,6 +80,32 @@ djapi — Django 5.2 金融数据 API 项目,2026-06-17 已部署。
| `getdiv/` | Tushare | 股息率(TTM rolling + 毛刺平滑) |
| `xwlbNews/` | MySQL | 新闻联播原始文本 |
| `xwlbFine/` | MySQL | 新闻联播 AI 精编 |
| `news/reports/` | MySQL (news_) | 日报查询:默认最近 24h;传 id 返回详情含事件 |
| `news/events/` | MySQL (news_) | 重要事件聚合:最近 N 天 importance≥阈值 |
---
## 日报查询 API2026-08-03 新增)
### 模块
- 新增 `api/report/` 包(独立于 stock):`query.py`(连库+查询 SQL/ `views.py`2 视图)/ `serializers.py`OpenAPI/ `tests.py`17 个单测,mock 查询层)
- `api/urls.py` 注册 `news/reports/``news/events/``settings.py` SPECTACULAR TAGS 加「日报」
- 数据库:doorcome 本机 MariaDB `myquant``news_report`180 行)+ `news_event`4372 条),与现有 `MYSQL_*` 同库同用户
- 连接配置:服务器 `djapi/.env` 新增 `NEWS_DB_*`(复用 MYSQL_* 值,密码必填否则 500
- 文档:`docs/news_report_api.md`(使用手册,含线上地址/curl/真实样例);README API 概览表已加两行
### 部署(2026-08-03 完成)
- rsync 增量同步(**未用文档中的 --delete**,见下)→ 重启 uWSGI → 冒烟通过(列表/详情/聚合/400/404)
- 线上:`https://api.doorcome.cn/api/news/reports/``/api/news/events/`Swagger `/api/docs/`「日报」tag
### 已知事项
1. **服务器顶层历史平铺文件未清理**`/home/simon/myquant/djapi/` 顶层有 views.py/urls.py/smoothBrush.py/getStockDiv2.py/env_loader.py/akshare_data.py(历史 rsync 陷阱产物),`--delete` 会删除它们,但 `divSearch.py`(离线脚本)仍绝对导入顶层 getStockDiv2/smoothBrush → 本次增量同步保留;清理前需先修 divSearch.py 的导入
2. **既有失败测试**`api.tests.DateFormatCorrectionTest.test_empty_string`date_format_correction('') 期望 None 实得 ''),与本次无关
3. 冒烟曾发现 fetch_reports 列表 SQL 缺 `r.` 别名前缀(1052 ambiguous),已修复
4. 本地验证需绕过 macOS TCC`HOME=/tmp/djtest_home PYTHONPATH=/tmp/djtest_pkgs`tushare 写 ~/tk.csv 被拦 + quant 环境缺 mysql-connector-python
## 部署