thread-master/docs/product/demand-radar/tasks/T532-sweep-failure-notify-a...

52 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# T532 — sweep-failure-notify-and-resume
> Status: `done`
> Milestone: `M2`
> Kind: `feat`
> Est. change: `~160 lines`
## Goal
完成後系統應sweep 失敗時 Sweep 記 `failed`+可讀原因並發站內通知;重跑不重判已完成的貼文。
## Depends on
- T527、T530
## Inputs
- Spec`../spec.md` §4.2.8、§5.4、§5.6、§7、§9.2SW-04
- 既有通知:`apps/backend/internal/module/notification/**`、`appnotif`
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/internal/module/radar/usecase/sweep_run.go` | edit | 錯誤收斂:抓取失敗/判定全數失敗 → Sweep `failed_reason`Job fail |
| `apps/backend/internal/module/radar/usecase/sweep_notify.go` | add | 失敗通知(`ref_type=sweep` 或既有雷達通知型別),落地雷達頁 |
| `apps/backend/internal/module/radar/usecase/judge_persist.go` | edit | 續跑:跳過 `judged_external_ids` 已含者 |
### 行為變更
- 抓取路徑不可用:**不回成功空資料**Sweep `failed` 並通知使用者「今天沒巡到,原因為 X」。
- 部分筆失敗Sweep 仍為成功但記錄失敗筆數與原因摘要。
- Job 中途失敗後重跑:已判定者不再扣點重判(避免重複計費)。
- 日誌不含 token 明文。
## Out of scope
- 前端空狀態文案T551
- 觀測列表 APIT533
## Acceptance
- [x] SW-04抓取不可用 → Sweep `failed`原因通知API 不回空成功
- [x] 中斷後重跑:`judged_count` 不重複累加、點數不重複扣
- [x] 指令:
```bash
cd apps/backend && go test ./internal/module/radar/... ./internal/module/notification/... -count=1
```