feat: real service test endpoints (proxy 7-route round-trip, core/chat/vlm/markbase/embedding), unified log paths + errorLog, pipeline tools/import/export/folder APIs, face pipeline check, dynamic concurrency tuning
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

This commit is contained in:
Accusys
2026-11-16 18:16:46 +08:00
parent d21d1ab960
commit 083d73d287
88 changed files with 12216 additions and 1096 deletions
+98
View File
@@ -901,6 +901,103 @@ struct ProcessorCountsResponse {
/// GET /api/v1/processor-json?file_hash=...&processor=...
/// Serves raw processor output JSON files from the output directory.
/// GET /api/v1/output-completeness
/// 檢查所有影片的產出完整性,回傳缺項清單。
/// 前端用此 API 將有缺項的 completed 卡片改為紅字顯示。
#[derive(serde::Serialize)]
struct OutputCompletenessItem {
file_uuid: String,
file_name: String,
status: String,
is_complete: bool,
missing: Vec<String>,
}
async fn get_output_completeness(
State(state): State<AppState>,
) -> Result<Json<serde_json::Value>, StatusCode> {
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
let videos_table = schema::table_name("videos");
let rows: Vec<(String, String, String)> = sqlx::query_as(&format!(
"SELECT file_uuid, file_name, status FROM {} WHERE file_type = 'video' ORDER BY file_name",
videos_table
))
.fetch_all(state.db.pool())
.await
.map_err(|e| {
tracing::error!("[output-completeness] DB query failed: {}", e);
StatusCode::INTERNAL_SERVER_ERROR
})?;
let mut items = Vec::new();
for (uuid, file_name, status) in rows {
if status != "completed" {
continue; // 只檢查 completed 的影片
}
let mut missing = Vec::new();
// 檢查 JSON 產出
for ext in ["asrx", "cut", "face", "face_cluster", "face_traced", "ocr", "scenes"] {
let path = format!("{}/{}.{}.json", output_dir, uuid, ext);
if !std::path::Path::new(&path).exists() {
missing.push(format!("{}.json", ext));
}
}
// 檢查 trace 目錄(如果有 faces)
let face_json = format!("{}/{}.face.json", output_dir, uuid);
if std::path::Path::new(&face_json).exists() {
if let Ok(content) = std::fs::read_to_string(&face_json) {
if let Ok(data) = serde_json::from_str::<serde_json::Value>(&content) {
let total_faces = data
.get("total_faces")
.or_else(|| data.get("data").and_then(|d| d.get("total_faces")))
.and_then(|v| v.as_u64())
.unwrap_or(0);
if total_faces > 0 {
let trace_base = std::path::Path::new(&output_dir).join(&uuid);
if trace_base.is_dir() {
if let Ok(entries) = std::fs::read_dir(&trace_base) {
for entry in entries.filter_map(|e| e.ok()) {
let name = entry.file_name().to_string_lossy().to_string();
if name.starts_with("trace_") && entry.path().is_dir() {
for f in ["key_face.jpg", "key_frame.jpg", "trace_profile.json"] {
if !entry.path().join(f).exists() {
missing.push(format!("{}/{}", name, f));
}
}
}
}
}
}
}
}
}
}
items.push(OutputCompletenessItem {
file_uuid: uuid,
file_name,
status,
is_complete: missing.is_empty(),
missing,
});
}
let complete_count = items.iter().filter(|i| i.is_complete).count();
let incomplete_count = items.len() - complete_count;
Ok(Json(serde_json::json!({
"total": items.len(),
"complete": complete_count,
"incomplete": incomplete_count,
"items": items,
})))
}
async fn get_processor_json(
Query(params): Query<std::collections::HashMap<String, String>>,
) -> Result<Json<serde_json::Value>, (StatusCode, Json<serde_json::Value>)> {
@@ -1156,6 +1253,7 @@ async fn trigger_vlm_summary(
pub fn processing_routes() -> Router<AppState> {
Router::new()
.route("/api/v1/output-completeness", get(get_output_completeness))
.route("/api/v1/file/:file_uuid/process", post(trigger_processing))
.route(
"/api/v1/file/:file_uuid/json/:processor",