58 lines
1.7 KiB
Markdown
58 lines
1.7 KiB
Markdown
# T033 — 結果分頁與 legacy run
|
||
|
||
> Status: `done`
|
||
> Milestone: `M3`
|
||
> Est. change: `~190 lines`
|
||
|
||
## Goal
|
||
|
||
完成後,新 run 結果與缺 run_id 的舊貼文都能按 Spec 依 score 穩定分頁,且同分未知 posted_at 置底。
|
||
|
||
## Depends on
|
||
|
||
- T032
|
||
|
||
## Inputs
|
||
|
||
- 讀取 / 依賴:
|
||
- 檔案:`apps/backend/internal/module/scout/repository/{memory,mongo}.go`
|
||
- 既有能力 / API:Post.RunID、canonical identity、run query contract
|
||
- Spec 段落:§4 流程 E、§6.1、§9 #8–#11
|
||
|
||
## Outputs
|
||
|
||
### 程式變更(預期路徑)
|
||
|
||
| 路徑 | 動作 | 說明 |
|
||
|------|------|------|
|
||
| `apps/backend/internal/module/scout/repository/memory.go` | edit | 實作 score/同分時間排序、legacy synthetic grouping 與 page total。 |
|
||
| `apps/backend/internal/module/scout/repository/mongo.go` | edit | 實作等價 Mongo query/aggregation 與 stable tie-breaker。 |
|
||
| `apps/backend/internal/module/scout/repository/run_paging_contract_test.go` | add | 同案例驗證 memory/Mongo 契約。 |
|
||
|
||
### 行為變更
|
||
|
||
- legacy 同 owner+theme 只形成一個 synthetic run;canonical duplicates 只顯示偏好項。
|
||
|
||
### API / 契約(若有)
|
||
|
||
- score desc;同分 posted_at > 0 在未知前,再以 created_at/ID desc。
|
||
|
||
## Out of scope
|
||
|
||
- 不猜測 legacy 同 theme 的歷史執行次數。
|
||
|
||
## Acceptance
|
||
|
||
- [x] 27 筆跨頁 unique count 等於 total,重複查詢順序一致。
|
||
- [ ] 指令:
|
||
|
||
```bash
|
||
cd apps/backend && go test ./internal/module/scout/repository -run RunPaging -count=1
|
||
```
|
||
|
||
驗收結果:Memory RunPaging 驗證 27 筆跨頁唯一、legacy synthetic run、未知時間置底與穩定 tie-breaker;Mongo 查詢含 posted/created/id 排序。
|
||
|
||
## Notes
|
||
|
||
Mongo 若需兩段排序,行為結果必須與 memory contract 一致。
|