比价记录失败卡展示具体原因(新增 fail_reason) #189

Merged
guke merged 1 commits from compare-record-fail-reason into main 2026-07-28 14:04:38 +08:00
Member

失败记录不再一律「网络开小差」:新增记录级 fail_reason 派生列——information
具体则直出,笼统则从 platform_results 救出业务原因(找不到店/菜、未起送、打烊、
单点不配送等),纯系统失败为 None → 端侧品牌兜底。store_closed/no_delivery 被
pricebot 漏成 status=failed 的按 reason 补判,打烊脏店名统一简短模板。接入
harvest_done 与灰度期 upsert_record 两条写路径。

  • models: comparison_record.fail_reason 列
  • repositories: _derive_fail_display + 补判/清洗 helper,两条写路径接入
  • schemas: ComparisonRecordOut 暴露 fail_reason
  • alembic: 加列 + 回填老 specific 失败记录
  • tests: _derive_fail_display 单测(8 例)+ harvest 失败落库集成测试

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

失败记录不再一律「网络开小差」:新增记录级 fail_reason 派生列——information 具体则直出,笼统则从 platform_results 救出业务原因(找不到店/菜、未起送、打烊、 单点不配送等),纯系统失败为 None → 端侧品牌兜底。store_closed/no_delivery 被 pricebot 漏成 status=failed 的按 reason 补判,打烊脏店名统一简短模板。接入 harvest_done 与灰度期 upsert_record 两条写路径。 - models: comparison_record.fail_reason 列 - repositories: _derive_fail_display + 补判/清洗 helper,两条写路径接入 - schemas: ComparisonRecordOut 暴露 fail_reason - alembic: 加列 + 回填老 specific 失败记录 - tests: _derive_fail_display 单测(8 例)+ harvest 失败落库集成测试 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
guke added 1 commit 2026-07-28 13:49:03 +08:00
失败记录不再一律「网络开小差」:新增记录级 fail_reason 派生列——information
具体则直出,笼统则从 platform_results 救出业务原因(找不到店/菜、未起送、打烊、
单点不配送等),纯系统失败为 None → 端侧品牌兜底。store_closed/no_delivery 被
pricebot 漏成 status=failed 的按 reason 补判,打烊脏店名统一简短模板。接入
harvest_done 与灰度期 upsert_record 两条写路径。

- models: comparison_record.fail_reason 列
- repositories: _derive_fail_display + 补判/清洗 helper,两条写路径接入
- schemas: ComparisonRecordOut 暴露 fail_reason
- alembic: 加列 + 回填老 specific 失败记录
- tests: _derive_fail_display 单测(8 例)+ harvest 失败落库集成测试

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
Member

🤖 review-pr 深审结论

🟢 可合并 — 逻辑正确、测试实跑通过、迁移干净。置信度 0.9(隔离 worktree 实跑 PG 测试 + alembic 校验 + 试合并)。

验证(隔离 worktree 实跑)

  • pytest tests/test_fail_reason.py tests/test_compare_harvest.py20 passed,跑在 PostgreSQL(conftest 的 shaguabijia_test)。新增失败派生测试 + 成功记录 fail_reason=None 断言均过;新测试用 user_id=None,PG 外键安全。
  • alembic heads单头 comparison_record_fail_reason,链路 user_manual_risk_fields → comparison_record_fail_reason 无分叉。
  • main 试合并:Already up to date(main 是 PR 祖先,无漂移)。
  • ComparisonRecordOut 仅被 compare_record 列表/详情/分页消费(admin 用独立 schema)→ 新增可选字段向后兼容,无共享类型破坏。

正面

  • _derive_fail_display[:256] 截断 + fail_reason 命名与既有 WithdrawOrder.fail_reason 约定一致。
  • 迁移列可空、回填只搬 specific 老记录;未回填的老 mixed/打烊记录回退兜底(注释已说明)。

nit(可选,不阻塞)

  • 救援命中多个目标同结局时只取首条 reason(可能少报「两个平台都…」);笼统 information 场景下已是净提升,低优先。
  • 回填 SQL 的笼统串列表与代码 _GENERIC_INFO 各写一份(迁移点时快照,可接受)。

配套:与 android #351 配对,建议 server 先上(含 alembic upgrade head)、android 后上。

## 🤖 review-pr 深审结论 🟢 **可合并** — 逻辑正确、测试实跑通过、迁移干净。置信度 **0.9**(隔离 worktree 实跑 PG 测试 + alembic 校验 + 试合并)。 **验证(隔离 worktree 实跑)** - `pytest tests/test_fail_reason.py tests/test_compare_harvest.py` → **20 passed**,跑在 **PostgreSQL**(conftest 的 `shaguabijia_test`)。新增失败派生测试 + 成功记录 `fail_reason=None` 断言均过;新测试用 `user_id=None`,PG 外键安全。 - `alembic heads` → **单头** `comparison_record_fail_reason`,链路 `user_manual_risk_fields → comparison_record_fail_reason` 无分叉。 - 与 `main` 试合并:**Already up to date**(main 是 PR 祖先,无漂移)。 - `ComparisonRecordOut` 仅被 compare_record 列表/详情/分页消费(admin 用独立 schema)→ 新增**可选**字段向后兼容,无共享类型破坏。 **正面** - `_derive_fail_display` 的 `[:256]` 截断 + `fail_reason` 命名与既有 `WithdrawOrder.fail_reason` 约定一致。 - 迁移列可空、回填只搬 specific 老记录;未回填的老 mixed/打烊记录回退兜底(注释已说明)。 **nit(可选,不阻塞)** - 救援命中多个目标同结局时只取首条 `reason`(可能少报「两个平台都…」);笼统 information 场景下已是净提升,低优先。 - 回填 SQL 的笼统串列表与代码 `_GENERIC_INFO` 各写一份(迁移点时快照,可接受)。 **配套**:与 android #351 配对,建议 **server 先上**(含 `alembic upgrade head`)、android 后上。
guke merged commit 50da718e35 into main 2026-07-28 14:04:38 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: WonderableAI/shaguabijia-app-server#189