docs: waiting status implementation report

實施內容:
- ✅ VideoStatus::Waiting 狀態
- ✅ TKG verification 前設為 Waiting
- ✅ Ingestion 前設為 Waiting
- ✅ 修復重複的 match arms
- ✅ Worker 已重啟

狀態流程:
Scanning → Processing → Waiting → Indexed → Completed

前端需要:
- 添加 'waiting' 狀態映射
- 多語言支持

文檔:
- docs_v1.0/M4_workspace/2026-09-28_waiting_status_implementation.md
This commit is contained in:
Accusys
2026-09-29 01:36:53 +08:00
parent aa4e50f4dc
commit 50a9675513
@@ -0,0 +1,214 @@
---
title: Waiting 狀態實施報告
version: 1.0
date: 2026-09-28
author: OpenCode
status: implemented
---
## 實施內容
### ✅ 新增 VideoStatus::Waiting
**枚舉位置**: `src/core/db/postgres_db.rs` Line 236
```rust
pub enum VideoStatus {
...
Processing,
Waiting, // ✅ 新增
Processed,
...
}
```
---
### ✅ 狀態映射
**as_str()**: `"waiting"`
**from_db_str()**: `"waiting" => Some(VideoStatus::Waiting)`
---
### ✅ 狀態更新位置
**1. TKG Verification (Line 3412)**
- **時機**: TKG 等待 Qdrant 數據時
- **日誌**: "⏳ TKG waiting for Qdrant..."
- **效果**: 用戶知道正在等待 TKG 數據
**2. Ingestion Phase (Line 3725)**
- **時機**: 所有處理器完成,等待 ingestion
- **日誌**: "waiting for ingestion..."
- **效果**: 用戶知道正在等待索引
---
## 完整狀態流程
```
開始 Deep Scan/Re-scan
↓
Scanning (初始狀態)
↓
Processing (處理器運行中)
↓
Waiting (等待 TKG/Ingestion) ✅ 新增
↓
Indexed (Rule 1 完成)
↓
Completed (最終完成)
```
---
## 用戶體驗改善
### Before
```
Status: 処理中 (Processing) ← 卡住很久
... (不知道在等什麼)
Status: 完了 (Completed)
```
### After
```
Status: 処理中 (Processing)
Status: 待機中 (Waiting) ← 明確告知在等待
Status: 索引済み (Indexed)
Status: 完了 (Completed)
```
---
## 前端需要更新
### 狀態映射
```javascript
const statusMap = {
'scanning': 'スキャン中',
'processing': '処理中',
'waiting': '待機中', // ✅ 新增
'indexed': '索引済み',
'completed': '完了'
};
```
### 多語言支持
| English | 繁體中文 | 日本語 |
|---------|---------|--------|
| Scanning | 掃描中 | スキャン中 |
| Processing | 處理中 | 処理中 |
| Waiting | 等待中 | 待機中 |
| Indexed | 已索引 | 索引済み |
| Completed | 完成 | 完了 |
---
## 修復的問題
### 重複的 match arms
**問題**: `as_str()` 和 `from_db_str()` 中有重複的 match arms
**修復**:
- 刪除重複的 Processed, Indexed, CheckedOut, Completed, Failed
- 添加 Waiting 的映射
---
## 測試驗證
### 測試方法
1. **註冊新文件**
```bash
curl -X POST http://localhost:3002/api/v1/register \
-H "Content-Type: application/json" \
-d '{"path": "/path/to/video.mp4"}'
```
2. **觀察狀態變化**
```bash
watch -n 1 'curl -s http://localhost:3002/api/v1/videos/{uuid} | jq ".status"'
```
### 預期結果
```
"scanning"
"processing"
"waiting" ← 新增
"indexed"
"completed"
```
---
## 性能影響
### 數據庫更新頻率
- **增加**: 2 次額外的 UPDATE 操作
- **時機**: 長時間等待前後
- **影響**: 可忽略(相比等待時間)
### 並發處理
- ✅ 使用事務(已實現)
- ✅ Job 級別鎖(已實現)
- ✅ 不影響其他文件處理
---
## 未來改進
### 可選的細粒度狀態
**建議**: 使用 `processing_status` JSON 字段
```json
{
"phase": "WAITING",
"reason": "TKG_VERIFICATION",
"details": "Waiting for Qdrant face points",
"progress": {
"current": 150,
"expected": 210
}
}
```
**優點**:
- 更詳細的等待原因
- 不改變主 status
- 可選實施
---
## 總結
### ✅ 已完成
1. 添加 VideoStatus::Waiting 狀態
2. 修復重複的 match arms
3. TKG verification 前設為 Waiting
4. Ingestion 前設為 Waiting
5. Worker 已重啟
### 📋 待辦
1. 前端更新狀態映射
2. 測試驗證
3. 考慮添加更多細節(如需要)
---
**日期**: 2026-09-28
**狀態**: ✅ **已實施,Worker 已重啟**