thread-master/docs/product/demand-radar/tasks/T528-sweep-fetch-reuse-dual...

57 lines
2.0 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.

# T528 — sweep-fetch-reuse-dual-path
> Status: `done`
> Milestone: `M2`
> Kind: `feat`
> Est. change: `~170 lines`
## Goal
完成後系統應:`radar_sweep` 以**既有海巡雙路徑**抓取(`dev_mode_enabled` 決定 apicrawler並在 Sweep 記 `path` 與命中數。
## Depends on
- T527
## Inputs
- Spec`../spec.md` §4.2.4、§4.2.8、§9.2SW-02SW-04、§6不新增第三種抓取
- 既有抓取:`apps/backend/internal/module/scout/usecase/**`api 路徑與 crawler 路徑分流)、`internal/module/search/**`
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/internal/module/radar/usecase/sweep_fetch.go` | add | 依 watch `terms``exclude_terms` 呼叫既有抓取入口,回統一的候選貼文結構 |
| `apps/backend/internal/module/radar/usecase/sweep_run.go` | add | sweep 主流程骨架:建 Sweep → 抓取 → 交給判定 → 收尾 |
| `apps/backend/internal/module/scout/usecase/**` | edit | **只做最小抽出**:把抓取入口暴露成可復用函式,不改既有行為 |
### 行為變更
- `dev_mode_enabled=false``path=api``true` 且有工作階段 → `path=crawler`
- `exclude_terms` 在抓取後過濾(抓取端不支援排除語法時)。
- 抓取路徑不可用 → 不吞錯,交由 T532 標記 `failed` 並通知;**禁止回成功空資料**。
- 抓取API 路徑)計入 `web_search` meter`source=radar.sweep`。
## Out of scope
- 判定與入庫T529T530
- 失敗通知與續跑T532
- 修改既有海巡三模式行為RG-01 必須不變)
## Acceptance
- [x] SW-02SW-03兩種 `dev_mode` 設定下 `path` 正確
- [x] RG-01既有海巡 briefscan 行為測試不變
- [x] 指令:
```bash
cd apps/backend && go test ./internal/module/radar/... ./internal/module/scout/... -count=1
```
## Notes
抽出時保持既有函式簽名與行為,只加一層可復用入口;不要順手重構海巡。