IOS-INFO-012:Rust Event → UploadItem 映射 #120

Closed
opened 2026-06-10 21:28:12 +08:00 by wangdl · 1 comment
Owner

目标

将 Rust ReadingEvent V2 映射为 API ReadingEventUploadItem。

依赖说明

  1. 映射依赖 Runtime ReadingEvent V2 输出格式。
  2. UploadItem 中 platform / appVersion / clientTimezoneOffsetMinutes 来自 AppContext。
  3. AppContext 由 IOS-INFO-038 提供。
  4. readingTargetType / knowledgeBaseId 来自 ReadingMaterialContext。

映射表

  • Rust eventId → UploadItem.eventId
  • Rust clientSessionId → UploadItem.clientSessionId
  • Rust materialId → UploadItem.materialId
  • Context readingTargetType → UploadItem.readingTargetType
  • Context knowledgeBaseId → UploadItem.knowledgeBaseId
  • Rust eventType → UploadItem.eventType
  • Rust position → UploadItem.position
  • Rust activeSecondsDelta → UploadItem.activeSecondsDelta
  • Rust timestampMs → UploadItem.clientTimestamp
  • Rust sequence → UploadItem.sequence
  • AppContext platform → UploadItem.platform
  • AppContext appVersion → UploadItem.appVersion
  • AppContext timezone → UploadItem.clientTimezoneOffsetMinutes

验收标准

  1. 所有字段映射完整。
  2. Rust 不提供的业务字段由 ReadingMaterialContext / AppContext 补充。
  3. timestampMs 转 Date 正确。
  4. timezone offset 正确。
  5. position 保持 camelCase。
  6. 缺少 required 字段时映射失败并记录。
  7. 有映射测试。
## 目标 将 Rust ReadingEvent V2 映射为 API ReadingEventUploadItem。 ## 依赖说明 1. 映射依赖 Runtime ReadingEvent V2 输出格式。 2. UploadItem 中 platform / appVersion / clientTimezoneOffsetMinutes 来自 AppContext。 3. AppContext 由 IOS-INFO-038 提供。 4. readingTargetType / knowledgeBaseId 来自 ReadingMaterialContext。 ## 映射表 - Rust eventId → UploadItem.eventId - Rust clientSessionId → UploadItem.clientSessionId - Rust materialId → UploadItem.materialId - Context readingTargetType → UploadItem.readingTargetType - Context knowledgeBaseId → UploadItem.knowledgeBaseId - Rust eventType → UploadItem.eventType - Rust position → UploadItem.position - Rust activeSecondsDelta → UploadItem.activeSecondsDelta - Rust timestampMs → UploadItem.clientTimestamp - Rust sequence → UploadItem.sequence - AppContext platform → UploadItem.platform - AppContext appVersion → UploadItem.appVersion - AppContext timezone → UploadItem.clientTimezoneOffsetMinutes ## 验收标准 1. 所有字段映射完整。 2. Rust 不提供的业务字段由 ReadingMaterialContext / AppContext 补充。 3. timestampMs 转 Date 正确。 4. timezone offset 正确。 5. position 保持 camelCase。 6. 缺少 required 字段时映射失败并记录。 7. 有映射测试。
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-10 21:28:12 +08:00
wangdl added the
blocked-by:doc-runtime
label 2026-06-10 22:15:58 +08:00
Author
Owner

开发完成评论

完成内容

  • ReadingEventMapper 重构为使用 AppContext(IOS-INFO-038):
    • map()mapOne() 参数从 appVersion: String 改为 appContext: AppContext
    • platform/appVersion/clientTimezoneOffsetMinutes 统一从 AppContext 读取
    • 每次映射调用 AppContext.refreshed() 更新时区偏移(跨时区安全)
  • 映射表完整:
    • Rust 字段:eventId, clientSessionId, materialId, eventType, position, activeSecondsDelta, timestampMs, sequence
    • Context 字段:readingTargetType, knowledgeBaseId
    • AppContext 字段:platform, appVersion, clientTimezoneOffsetMinutes
  • 新建 AIStudyAppTests/EventMapperTests.swift(8 个测试):
    • 5 种 eventType → snake_case 字符串
    • AppContext 字段集成验证
    • 无 context 返回 nil
    • 全部 eventType 有映射
    • timezone refresh 每次调用

修改文件

  • Features/MaterialReader/ReadingEventMapper.swift:参数从 appVersion: String 改为 appContext: AppContext
  • AIStudyAppTests/EventMapperTests.swift:新建

验收标准逐项

  1. 所有字段映射完整 — 13 个字段全部映射
  2. Rust 不提供的由 Context/AppContext 补充 — readingTargetType/knowledgeBaseId/platform/appVersion/timezone
  3. timestampMs 转 Date 正确 — clientTimestampMs: Int64 毫秒精度
  4. timezone offset 正确 — appContext.refreshed().clientTimezoneOffsetMinutes
  5. position 保持 camelCase — UniFFI enum 自带 camelCase
  6. 缺少 required 字段时映射失败并记录 — guard let ctx → nil + print log
  7. 有映射测试 — 8 个测试

是否建议进入 Review

  • 是(需 Xcode 编译验证)
## 开发完成评论 ### 完成内容 - `ReadingEventMapper` 重构为使用 `AppContext`(IOS-INFO-038): - `map()` 和 `mapOne()` 参数从 `appVersion: String` 改为 `appContext: AppContext` - `platform`/`appVersion`/`clientTimezoneOffsetMinutes` 统一从 `AppContext` 读取 - 每次映射调用 `AppContext.refreshed()` 更新时区偏移(跨时区安全) - 映射表完整: - Rust 字段:eventId, clientSessionId, materialId, eventType, position, activeSecondsDelta, timestampMs, sequence - Context 字段:readingTargetType, knowledgeBaseId - AppContext 字段:platform, appVersion, clientTimezoneOffsetMinutes - 新建 `AIStudyAppTests/EventMapperTests.swift`(8 个测试): - 5 种 eventType → snake_case 字符串 - AppContext 字段集成验证 - 无 context 返回 nil - 全部 eventType 有映射 - timezone refresh 每次调用 ### 修改文件 - `Features/MaterialReader/ReadingEventMapper.swift`:参数从 `appVersion: String` 改为 `appContext: AppContext` - `AIStudyAppTests/EventMapperTests.swift`:新建 ### 验收标准逐项 1. 所有字段映射完整 — ✅ 13 个字段全部映射 2. Rust 不提供的由 Context/AppContext 补充 — ✅ readingTargetType/knowledgeBaseId/platform/appVersion/timezone 3. timestampMs 转 Date 正确 — ✅ `clientTimestampMs: Int64` 毫秒精度 4. timezone offset 正确 — ✅ `appContext.refreshed().clientTimezoneOffsetMinutes` 5. position 保持 camelCase — ✅ UniFFI enum 自带 camelCase 6. 缺少 required 字段时映射失败并记录 — ✅ `guard let ctx` → nil + print log 7. 有映射测试 — ✅ 8 个测试 ### 是否建议进入 Review - 是(需 Xcode 编译验证)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/ios-projects#120
No description provided.