forked from wangziqi/gongxue-base
perf: stabilize real pocketbase import
This commit is contained in:
@@ -143,7 +143,7 @@ auxiliary.db: _logs 121715 条,仅摘要
|
||||
|
||||
当前导入器已经补齐下面 4 个旧集合的标准化 mapper:
|
||||
|
||||
- `user_answer_records` 85442 条会导入到 `answer_records`,并按错误记录重建 `wrong_questions`。
|
||||
- `user_answer_records` 85442 条会导入到 `answer_records`,并按错误记录重建 `wrong_questions`。旧用户为空或旧用户已不存在的答题记录会跳过并写 warning,不作为财务/权益级 blocker。
|
||||
- `mock_exam_configs` 48 条会导入到 `practice_blueprints(mode='mock_exam', assembly_type='filters')`。
|
||||
- `referral_qrcodes` 79 条会导入到 `referral_qrcodes`,并同步补 `referral_codes`。
|
||||
- `commission_settings` 1 条会导入到 `tenant_commission_settings`。
|
||||
@@ -158,7 +158,38 @@ production dry-run 还有这些 warning,属于运营处理项:
|
||||
- `dashboard_cache`、空 `customer_messages/smscodes/tenant_config` 可不作为正式数据源,必要时只保留审计摘要。
|
||||
- `recent_practices` 和少量 `user_answer_records` 有旧用户引用断裂,需要在导入后复核 `pb_import_issues`。
|
||||
|
||||
性能注意:真实 `pb:import:json` 试跑已经证明 248555 条真实记录会超过 10 分钟。正式迁移前需要继续优化 importer 的批量写入和分批事务,重点是 `pb_raw_records`、`questions/question_versions`、`user_answer_records`。迁移演练必须记录总耗时、每阶段耗时和失败恢复策略。
|
||||
最新真实导入演练结果:
|
||||
|
||||
```text
|
||||
环境:本地 Supabase,先执行 npx supabase db reset
|
||||
命令:npm run pb:import:json
|
||||
耗时:约 8 分 58 秒
|
||||
导入后校验:npm run pb:import:validate => 0 failures, 3 warnings
|
||||
|
||||
核心计数:
|
||||
platform_users: 3670
|
||||
questions: 74102
|
||||
answer_records: 85199
|
||||
wrong_questions: 38205
|
||||
orders: 636
|
||||
entitlements: 447
|
||||
practice_blueprints(mode=mock_exam): 48
|
||||
referral_qrcodes: 79
|
||||
tenant_commission_settings: 1
|
||||
```
|
||||
|
||||
最新导入 run 的 `pb_import_issues` 仍有 29 个 critical,需要正式切换前人工复核:
|
||||
|
||||
- 7 个 `orders` 已支付订单缺用户:订单会进入财务复核,不自动开通权益。
|
||||
- 22 个 `handbook_chapters` 缺所属手册:章节会挂到“迁移待复核手册”。
|
||||
|
||||
导入后校验的 3 个 warnings 当前含义:
|
||||
|
||||
- 2533 道题保留 `legacy_category_id` 但无法解析到旧 `categories/module_nodes`,原始 `categoryId` 与 `nodeId` 相同,且旧导出中已没有对应分类或节点。不能由导入器硬绑到错误分类,需后续按科目/题型人工归档或在内容后台批量挂载。
|
||||
- 5298 条旧答题记录保留 `legacy_question_id` 但无法解析到题目,说明旧学习日志引用了已删除/未导出的题目;这些记录不会进入错题本有效组卷。
|
||||
- 最新 run 存在 29 个 critical import issues,即上面的付费订单和手册章节人工复核项。
|
||||
|
||||
性能注意:真实 `pb:import:json` 已能在 9 分钟左右完成 248555 条真实记录导入。后续若题库规模继续增长,仍建议继续批量化 `questions/question_versions` 并补阶段耗时统计、失败恢复和断点重跑策略。
|
||||
|
||||
## 阶段 1:静态 Dry-Run
|
||||
|
||||
@@ -265,6 +296,12 @@ Remove-Item Env:\FAIL_ON_WARNINGS
|
||||
- `tenant_settings.public_config` 不含密钥。
|
||||
- `crm_config.secret_ref` 只引用 `app_private.tenant_secrets`。
|
||||
|
||||
当前演练可接受但上线前必须确认的 warning:
|
||||
|
||||
- 已支付订单缺用户不能自动开权益,必须由财务/运营确认是否补绑用户、退款、作废或保留售后台账。
|
||||
- 手册章节缺归属需要内容负责人确认归并到正确手册,或保留在迁移待复核手册并在前端隐藏。
|
||||
- 已删除分类下的题目和已删除题目对应的学习记录,需要按运营口径决定是否建立“迁移待复核分类”、按科目批量归档,或仅保留 legacy trace。
|
||||
|
||||
## 阶段 4:抽样验收
|
||||
|
||||
每次演练都应至少抽样下面数据:
|
||||
|
||||
Reference in New Issue
Block a user