2.0 KiB
2.0 KiB
T528 — sweep-fetch-reuse-dual-path
Status:
done
Milestone:M2
Kind:feat
Est. change:~170 lines
Goal
完成後系統應:radar_sweep 以既有海巡雙路徑抓取(dev_mode_enabled 決定 api/crawler),並在 Sweep 記 path 與命中數。
Depends on
- T527
Inputs
- Spec:
../spec.md§4.2.4、§4.2.8、§9.2(SW-02~SW-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_searchmeter/source=radar.sweep。
Out of scope
- 判定與入庫(T529/T530)
- 失敗通知與續跑(T532)
- 修改既有海巡三模式行為(RG-01 必須不變)
Acceptance
- SW-02/SW-03:兩種
dev_mode設定下path正確 - RG-01:既有海巡 brief/scan 行為測試不變
- 指令:
cd apps/backend && go test ./internal/module/radar/... ./internal/module/scout/... -count=1
Notes
抽出時保持既有函式簽名與行為,只加一層可復用入口;不要順手重構海巡。