6 Commits

Author SHA1 Message Date
pmc
61e8374e6a fix(affinity-P1): WR-002~WR-009 + IN-001~IN-006 综合改进收尾
WR-002 UserLevelRewardGrant.device on_delete CASCADE → SET_NULL,加 device_snapshot_id,
  unique 改为 partial(device 非空时唯一),与 AffinityLog.device SET_NULL 对齐
WR-003 AffinityLog 删除 3 个低价值索引(user/rule_key/source -created_at 复合)
WR-004 event_id 改为 null=True,partial unique 用 isnull=False;RunPython '' → NULL
WR-005 seed 加 companion_30min 默认规则
WR-006 description 显式 default='';DEFAULT_LEVELS 全部补 description
WR-007 seed_affinity 每条 spec 独立事务,部分失败可重跑
WR-008 ParadiseUser.favorability 字段保留 + UserInfoSerializer 移除暴露 + [DEPRECATED] 标记
WR-009(见 Commit B:AffinityLevel.clean + save full_clean 多层兜底)
IN-001 5 个弃用字段 help_text 加 [DEPRECATED — 计划于 P2 完成后删除]
IN-002 DEFAULT_RULES/LEVELS/SETTING 抽到 userapp/affinity/defaults.py
IN-003 AffinitySetting.daily_cap RenameField → global_daily_cap(区分 AffinityRule.daily_cap)
IN-004 AffinityLog.__str__ 用 pk or 'new' 兜底 None
IN-005(见 Commit A:is_active → is_bound 改名)
IN-006(见 Commit C:0006 print 前缀改为 [migration 0006_...])

迁移 0009 手工修正:daily_cap 改名用 RenameField(保留数据),不是 Remove+Add;
event_id '' → NULL 数据兜底;UserLevelRewardGrant on_delete + conditional unique 重建。

详见 docs/REVIEW-affinity-P1.md WR-* / IN-* 与 FIX-REPORT.md。
2026-05-13 10:18:47 +08:00
pmc
2a28aa8b28 fix(affinity-P1): CR-003 修正 0006 数据迁移幂等性
旧 forward 用 target.favorability == 10 判断"未迁移",10 既是初始值也是衰减
常见值,重跑会覆盖合法数据;backward 用 != 10 反向判断会丢衰减回 10 的数据。

改用 AffinityLog source='data_migration' 标记做幂等:
  - forward 写入新值时同步写一条 audit log,metadata 含原 ParadiseUser 值
  - backward 遍历 audit log 反向恢复并删除标记,保证 forward/backward 可循环

同步:AffinityLog.SOURCE_CHOICES 追加 'data_migration' + 0008 AlterField 迁移
更新 Python 端 choices 校验。

option B 选择:直接重写 0006(dev 已跑过但 migrate_count=0 等于未动数据,
django_migrations 表已记录完成不会再跑)。生产部署前需确认 prod 未跑过 0006,
否则需 fake-reverse 流程,详见迁移文件 docstring 与 FIX-REPORT。

详见 docs/REVIEW-affinity-P1.md CR-003。
2026-05-13 10:13:31 +08:00
pmc
9a87f5e2b5 fix(affinity-P1): CR-002 + WR-001 加 Affinity 模型 DB CHECK 约束 + 单例硬约束
AffinityRule / AffinityLevel / AffinitySetting 三表共 13 条 CheckConstraint
覆盖 min ≤ max / 各类 cap > 0 / cooldown ≥ 0 / companion_time 配套字段必填 /
decay 区间合法 / initial ≤ max 等不变量。

AffinitySetting 加 pk=1 单例硬约束(CR-002 + WR-001 联动)+ save() 强制 pk=1,
形成事实单例防御并发首次插入重复行。

模型 clean() 提供 Python 级兜底(给 DRF / admin 友好错误信息);
AffinityLevel.save() 自动 full_clean 触发跨行区间不重叠校验(为 WR-009 铺路)。

详见 docs/REVIEW-affinity-P1.md CR-002 / WR-001。
2026-05-13 10:12:01 +08:00
pmc
2d82b2ef7f feat: implement affinity (favorability) system
All checks were successful
Build and Deploy LTY / build-and-deploy (push) Successful in 8m44s
- Add affinity level/setting models and migrations
- Migrate favorability data to UserDevice
- Add management commands for userapp
- Add admin CLAUDE.md and docs
- Update affinity system design doc and task checklist
- Update device_interaction and userapp models

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 17:18:30 +08:00
pmc
bd95ba470c feat: update admin panel, API modules, and add migrations
- Update food, outfits, props, home-decor pages and components
- Add permissions page and sidebar updates
- Update API client and all API modules (auth, food, dances, etc.)
- Add card model migrations for optional fields
- Update Django views, serializers, and authentication
- Add affinity level migrations and user app updates
- Add project documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-20 13:06:50 +08:00
zyc
0c610c1e49 first commit 2026-03-17 13:17:02 +08:00