修复:首页轮播排除测试账号数据 #215
Reference in New Issue
Block a user
Delete Branch "codex/marquee-exclude-test-account"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
背景
线上首页轮播候选记录中,测试账号 u33(11111111111)贡献约 51.8% 的真实记录,导致该用户频繁出现。
改动
验证
🤖 review-pr 深审结论
🟢 可合并 · 0.9 — 首页轮播(App + 后台)查询排除已配置测试账号,改动干净、定向、有测试;合并最新
main后实跑test_ops_marquee.py1 passed。改动(2 文件 +98/-7)
app/repositories/ops_marquee.py:_recent_real_rows与后台list_real_records两条真实记录查询,均在settings.test_account_phones非空时加User.phone.not_in(test_phones)。_real_rows_cache增加test_phones维度:测试账号配置变化时缓存立即失效(比对不等 → 重查),避免旧缓存继续带测试号。核对
settings.test_account_phones(config.py:208)是既有属性,取并集TEST_ACCOUNT_PHONE(旧单值) +TEST_ACCOUNT_PHONES(新逗号分隔),本 PR 用法正确;测试同时 monkeypatch 两者并断言都被排除。User.phone为nullable=False(user.py:28),故NOT IN的三值逻辑不会误伤真实 NULL 手机号(不存在此类行)。if test_phones:守卫 —— 未配置测试号时不加过滤,行为与原来完全一致。构建 / 测试(已实跑,诚实)
main(PR head 已含最新 main)后隔离 worktree 实跑:tests/test_ops_marquee.py→ 1 passed(旧号 + 列表号 + 真实号三方隔离,验证前两者被排除、真实号保留)。建议
🤖 自动深审 · 全程只读 · 合并 base 后隔离 worktree 实跑 pytest