API-INFO-000 P0 | 学习信息收集总设计与实体映射 【status:todo】 #128

Closed
opened 2026-06-07 11:22:53 +08:00 by wangdl · 2 comments
Owner

目标

冻结学习信息收集的数据模型、实体映射、readingTargetType、核心聚合链路。

核心设计决策

readingTargetType

knowledge_source: materialId = KnowledgeSource.id, knowledgeBaseId = KnowledgeSource.knowledgeBaseId
temporary_file: materialId = TemporaryReadingMaterial.id, knowledgeBaseId = null (后续可补)

activeSecondsDelta

  • Rust active_seconds 为累计值,API 只收增量 activeSecondsDelta
  • 转换由 iOS 适配层完成,API 不做差值计算

核心链路

ReadingEvent → LearningSession → MaterialReadingProgress → DailyLearningActivity → LearningRecord → continue/summary/trend/heatmap/history

其他决策

  • 上报接口不返回 latestProgress,进度查询独立
  • activeSecondsDelta=0 合法,<0 非法,>300 截断
  • MaterialClosed 无 position 时不覆盖已有 position
  • 同步聚合(暂不用 worker)
  • 不用 @nestjs/schedule,用写路径懒清理

验收标准

  1. docs/learning-info-design.md 存在
  2. 明确 readingTargetType
  3. 明确 materialId 映射
  4. 明确权限校验方式
## 目标 冻结学习信息收集的数据模型、实体映射、readingTargetType、核心聚合链路。 ## 核心设计决策 ### readingTargetType ```text knowledge_source: materialId = KnowledgeSource.id, knowledgeBaseId = KnowledgeSource.knowledgeBaseId temporary_file: materialId = TemporaryReadingMaterial.id, knowledgeBaseId = null (后续可补) ``` ### activeSecondsDelta - Rust active_seconds 为累计值,API 只收增量 activeSecondsDelta - 转换由 iOS 适配层完成,API 不做差值计算 ### 核心链路 ``` ReadingEvent → LearningSession → MaterialReadingProgress → DailyLearningActivity → LearningRecord → continue/summary/trend/heatmap/history ``` ### 其他决策 - 上报接口不返回 latestProgress,进度查询独立 - activeSecondsDelta=0 合法,<0 非法,>300 截断 - MaterialClosed 无 position 时不覆盖已有 position - 同步聚合(暂不用 worker) - 不用 @nestjs/schedule,用写路径懒清理 ## 验收标准 1. docs/learning-info-design.md 存在 2. 明确 readingTargetType 3. 明确 materialId 映射 4. 明确权限校验方式
wangdl added this to the M8:学习信息收集与基础分析闭环 milestone 2026-06-07 11:22:53 +08:00
wangdl changed title from API-INFO-000 P0 | 学习信息收集总设计与实体映射 to API-INFO-000 P0 | 学习信息收集总设计与实体映射 【status:todo】 2026-06-07 19:04:08 +08:00
Author
Owner

审查结论:当前 API 项目学习信息收集体系基本为全新建设。可复用:JWT Guard、LearningSession 基础表/CRUD、DailyLearningActivity 基础表、ActivityController 部分接口、LearningRecord schema。其余 ReadingEvent/TemporaryMaterial/Progress/批量上报/Processor/聚合/查询接口/错误码/去重/权限/测试/文档均不存在或仅部分存在。

本 Issue: 设计文档不存在。全新建设。

标签: audit:reviewed audit:api-info status:todo work:contract,work:docs

## 审查结论:当前 API 项目学习信息收集体系基本为全新建设。可复用:JWT Guard、LearningSession 基础表/CRUD、DailyLearningActivity 基础表、ActivityController 部分接口、LearningRecord schema。其余 ReadingEvent/TemporaryMaterial/Progress/批量上报/Processor/聚合/查询接口/错误码/去重/权限/测试/文档均不存在或仅部分存在。 **本 Issue**: 设计文档不存在。全新建设。 **标签**: audit:reviewed audit:api-info status:todo work:contract,work:docs
Author
Owner

完成报告

交付

docs/learning-info-design.md — 学习信息收集总设计文档,包含:

1. readingTargetType 定义

  • knowledge_source: materialId = KnowledgeSource.id, knowledgeBaseId = KnowledgeSource.knowledgeBaseId
  • temporary_file: materialId = TemporaryReadingMaterial.id, knowledgeBaseId = null

2. 实体映射

  • 新增 3 表:ReadingEvent / MaterialReadingProgress / TemporaryReadingMaterial
  • 扩展 2 表:LearningSession (+6 字段) / DailyLearningActivity (+2 字段)
  • 复用 1 表:LearningRecord (不改 schema,扩 recordType)

3. 核心聚合链路

ReadingEvent → LearningSession → MaterialReadingProgress → DailyLearningActivity → LearningRecord → 查询接口

4. 设计决策

  • 同步聚合(暂不用 worker)
  • activeSecondsDelta=0 合法,<0 非法,>300 截断
  • MaterialClosed 无 position 不覆盖已有
  • 乱序事件不拒绝(容忍时钟漂移)

5. 错误码定义:8 种(DUPLICATE_EVENT/INVALID_DELTA/DELTA_EXCEEDED 等)

6. 权限校验:JWT guard + userId + 资源归属

7. 接口列表:8 个接口

## 完成报告 ### 交付 `docs/learning-info-design.md` — 学习信息收集总设计文档,包含: **1. readingTargetType 定义** - `knowledge_source`: materialId = KnowledgeSource.id, knowledgeBaseId = KnowledgeSource.knowledgeBaseId - `temporary_file`: materialId = TemporaryReadingMaterial.id, knowledgeBaseId = null **2. 实体映射** - 新增 3 表:ReadingEvent / MaterialReadingProgress / TemporaryReadingMaterial - 扩展 2 表:LearningSession (+6 字段) / DailyLearningActivity (+2 字段) - 复用 1 表:LearningRecord (不改 schema,扩 recordType) **3. 核心聚合链路** ``` ReadingEvent → LearningSession → MaterialReadingProgress → DailyLearningActivity → LearningRecord → 查询接口 ``` **4. 设计决策** - 同步聚合(暂不用 worker) - activeSecondsDelta=0 合法,<0 非法,>300 截断 - MaterialClosed 无 position 不覆盖已有 - 乱序事件不拒绝(容忍时钟漂移) **5. 错误码定义**:8 种(DUPLICATE_EVENT/INVALID_DELTA/DELTA_EXCEEDED 等) **6. 权限校验**:JWT guard + userId + 资源归属 **7. 接口列表**:8 个接口
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#128
No description provided.