- 新增 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 事件)+ 幂等覆盖
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""日报结构化入库:数据模型。
|
|
|
|
与 news 项目 report_db/models.py 保持一致(intl 板块复用同一表结构)。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import date, datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class EventRow(BaseModel):
|
|
"""一条事件记录,对应 news_event 一行。"""
|
|
|
|
section: str # xwlb | news | cninfo | intl
|
|
rank: int # 板块内序号(从 1 开始)
|
|
importance: int | None = None
|
|
event_type: str | None = None
|
|
title: str
|
|
summary: str | None = None
|
|
sentiment: str | None = None # positive | negative | neutral | ''
|
|
source: str | None = None
|
|
url: str | None = None
|
|
|
|
|
|
class ReportData(BaseModel):
|
|
"""一份完整日报:news_report 一行 + news_event 多行。"""
|
|
|
|
report_date: date
|
|
report_type: str # finance | intl
|
|
file_name: str = "" # 源文件名(新生成日报可为空)
|
|
generated_at: datetime
|
|
ai_summary: str | None = None
|
|
stats: dict[str, Any] = Field(default_factory=dict)
|
|
events: list[EventRow] = Field(default_factory=list)
|