thread-master/docs/product/demand-radar/tasks/T545-today-api-stats-and-em...

51 lines
1.8 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.

# T545 — today-api-stats-and-empty-reasons
> Status: `done`
> Milestone: `M3`
> Kind: `feat`
> Est. change: `~180 lines`
## Goal
完成後系統應:`GET /api/v1/radar/today` 回今日筆數低分項首頁卡片0 筆時回**明確原因與下一步**。
## Depends on
- T525、T526
## Inputs
- Spec`../spec.md` §4.4、§5.2、§9.3TD-01、TD-02
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/generate/api/radar.api` | edit | today resp type`stats`、`groups`、`empty_reason`、`truncated_count` |
| `apps/backend/internal/logic/radar/getRadarTodayLogic.go` | edit | 統計與卡片查詢 |
| `apps/backend/internal/module/radar/usecase/today.go` | add | 統計聚合+空狀態原因判定 |
### 行為變更
- 只計 `qualified``accepted``dismissed`**排除 `rejected`**)於今日名單;`rejected` 另有 filter 可查。
- 空狀態原因由後端判定並回列舉值+人話說明:`not_swept_yet`(未到巡的時間)/`all_watches_paused``no_watch``no_profile``sweep_failed``no_hit`(關鍵字太窄),各帶建議動作。
- 帶當日 `truncated_count` 供前端顯示「N 筆較低意向未收錄」。
- 卡片欄位:原文摘要、`intent_score`、`intent_band`、`region_detected`、`posted_at`ns前端換算、預設 `public_comment` 回覆(若已生成)。
## Out of scope
- 前端畫面T551
- 回覆生成T549
## Acceptance
- [x] TD-0118 筆 → 統計與分項正確、卡片欄位齊
- [x] TD-020 筆 → 回可辨識的 `empty_reason` 與建議,非空白 `list`
- [x] 指令:
```bash
cd apps/backend && make gen-api && go test ./internal/logic/radar/... ./internal/module/radar/... -count=1
```