IOS-INFO-012 P0 | Rust Event → UploadItem 映射 【审计: 不存在】 #77

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

映射

Rust eventId→eventId, clientSessionId→clientSessionId, context.readingTargetType→readingTargetType, Rust materialId→materialId, Rust eventType→eventType, Rust position→position, Rust activeSecondsDelta→activeSecondsDelta, Rust timestampMs→clientTimestampMs, Rust sequence→sequence, iOS→platform=ios, iOS→appVersion, iOS→timezoneOffset

## 映射 Rust eventId→eventId, clientSessionId→clientSessionId, context.readingTargetType→readingTargetType, Rust materialId→materialId, Rust eventType→eventType, Rust position→position, Rust activeSecondsDelta→activeSecondsDelta, Rust timestampMs→clientTimestampMs, Rust sequence→sequence, iOS→platform=ios, iOS→appVersion, iOS→timezoneOffset
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-07 11:55:26 +08:00
wangdl changed title from IOS-INFO-009 P0 | Rust Event → UploadItem 映射 to IOS-INFO-012 P0 | Rust Event → UploadItem 映射 【审计: 不存在】 2026-06-07 12:20:49 +08:00
Author
Owner

重构提醒(来自 Batch B 审查 F3)

blockId(from:)MaterialReaderView.swift:306-317ReadingPositionAdapter.swift:85-96 中重复定义。

实现本 issue 时一并处理:

  1. 删除 MaterialReaderView 中的 blockId(from:)
  2. 调用方改为 ReadingPositionAdapter.blockId(from:)(需将 helper 改为 internal/public)

或者两处都改为 DocumentBlock 的 extension computed property。

## 重构提醒(来自 Batch B 审查 F3) `blockId(from:)` 在 `MaterialReaderView.swift:306-317` 和 `ReadingPositionAdapter.swift:85-96` 中重复定义。 实现本 issue 时一并处理: 1. 删除 MaterialReaderView 中的 `blockId(from:)` 2. 调用方改为 `ReadingPositionAdapter.blockId(from:)`(需将 helper 改为 internal/public) 或者两处都改为 `DocumentBlock` 的 extension computed property。
Author
Owner

完成报告

交付

Features/MaterialReader/ReadingEventMapper.swift — Rust → API 映射器:

enum ReadingEventMapper {
    /// ReadingEventTypeV2 → snake_case (material_opened, etc.)
    static func apiEventType(_: ReadingEventTypeV2) -> String

    /// 批量映射: [ReadingEventV2] + contexts → [ReadingEventUploadItem]
    static func map(rustEvents:, contexts:, appVersion:) -> [ReadingEventUploadItem]

    /// 单条映射
    static func mapOne(event:, context:, appVersion:) -> ReadingEventUploadItem?
}

映射规则:

Rust Field Upload Item 处理
eventId eventId 直接映射
clientSessionId clientSessionId 直接映射
materialId materialId 直接映射
eventType (enum) eventType (String) switch → snake_case
position position 直接映射
activeSecondsDelta activeSecondsDelta UInt32 → Int
timestampMs clientTimestampMs 直接映射
sequence sequence 直接映射
readingTargetType context.readingTargetType.rawValue
platform "ios"
appVersion Bundle.main
clientTimezoneOffsetMinutes TimeZone.current

F3 修复: 删除 MaterialReaderView 中重复的 blockId(from:),统一使用 ReadingPositionAdapter.blockId(from:)

## 完成报告 ### 交付 `Features/MaterialReader/ReadingEventMapper.swift` — Rust → API 映射器: ```swift enum ReadingEventMapper { /// ReadingEventTypeV2 → snake_case (material_opened, etc.) static func apiEventType(_: ReadingEventTypeV2) -> String /// 批量映射: [ReadingEventV2] + contexts → [ReadingEventUploadItem] static func map(rustEvents:, contexts:, appVersion:) -> [ReadingEventUploadItem] /// 单条映射 static func mapOne(event:, context:, appVersion:) -> ReadingEventUploadItem? } ``` **映射规则:** | Rust Field | Upload Item | 处理 | |-----------|------------|------| | eventId | eventId | 直接映射 | | clientSessionId | clientSessionId | 直接映射 | | materialId | materialId | 直接映射 | | eventType (enum) | eventType (String) | switch → snake_case | | position | position | 直接映射 | | activeSecondsDelta | activeSecondsDelta | UInt32 → Int | | timestampMs | clientTimestampMs | 直接映射 | | sequence | sequence | 直接映射 | | — | readingTargetType | context.readingTargetType.rawValue | | — | platform | "ios" | | — | appVersion | Bundle.main | | — | clientTimezoneOffsetMinutes | TimeZone.current | **F3 修复:** 删除 `MaterialReaderView` 中重复的 `blockId(from:)`,统一使用 `ReadingPositionAdapter.blockId(from:)`
Sign in to join this conversation.
No description provided.