fix: scan.rs stats API 使用 per-library 路徑 — 修復 Scene VLM 數量不顯示
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

- get_file_stats_inner: output_dir 改 per-library(scene_vlm/face_cluster/vlm_summary stats)
- get_pipeline_progress_handler: output_dir 改 per-library
- get_ingestion_status: scene_meta_path 改 per-library
- get_scene_vlm_stats: output_dir 改 per-library
- 驗證: test library scene-vlm-stats 回傳 18 scenes, 18/18 done
This commit is contained in:
Accusys
2026-11-19 15:43:17 +08:00
parent 02ef25d4e7
commit a57e0bb433
+32 -9
View File
@@ -544,11 +544,14 @@ async fn get_ingestion_status(
let identity_count = identity_ids.len() as i64;
let strangers = stranger_traces.len() as i64;
let scene_meta_path = format!(
"{}/{}.scene_meta.json",
crate::core::config::OUTPUT_DIR.as_str(),
file_uuid
);
let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, pool).await;
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
let scene_meta_base = if std::path::Path::new(&per_lib_dir).is_dir() {
per_lib_dir
} else {
global_dir.to_string()
};
let scene_meta_path = format!("{}/{}.scene_meta.json", scene_meta_base, file_uuid);
let scene_meta_ok = std::path::Path::new(&scene_meta_path).exists();
macro_rules! count_sql {
@@ -1153,8 +1156,15 @@ async fn get_file_stats_inner(
..Default::default()
};
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, pool).await;
let output_dir: &str = if std::path::Path::new(&per_lib_dir).is_dir() {
&per_lib_dir
} else {
global_dir
};
// 6. Get Face Dedup stats
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid);
let face_clusters = if std::path::Path::new(&face_cluster_path).exists() {
if let Ok(content) = std::fs::read_to_string(&face_cluster_path) {
@@ -1330,6 +1340,15 @@ async fn get_pipeline_progress_handler(
State(state): State<AppState>,
Path(file_uuid): Path<String>,
) -> Result<Json<crate::core::progress::PipelineProgress>, StatusCode> {
// Per-library output dir (test files live in output/test)
let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await;
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
let output_dir: &str = if std::path::Path::new(&per_lib_dir).is_dir() {
&per_lib_dir
} else {
global_dir
};
// 1. Try to read existing progress from Redis first
let redis_progress: Option<crate::core::progress::PipelineProgress> = {
use crate::core::db::RedisClient;
@@ -1521,7 +1540,6 @@ async fn get_pipeline_progress_handler(
// Check scene_vlm progress from scenes.json
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
if std::path::Path::new(&scenes_path).exists() {
if let Ok(scenes_json) = std::fs::read_to_string(&scenes_path) {
@@ -1578,7 +1596,6 @@ async fn get_pipeline_progress_handler(
// Check face dedup from actual face_cluster.json content
// Always check if processors_done, regardless of tkg_node_count (A-10 fix)
if processors_done {
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid);
if std::path::Path::new(&face_cluster_path).exists() {
if let Ok(content) = std::fs::read_to_string(&face_cluster_path) {
@@ -1649,7 +1666,13 @@ pub async fn get_scene_vlm_stats(
State(state): State<AppState>,
Path(file_uuid): Path<String>,
) -> Result<Json<SceneVlmStats>, StatusCode> {
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
let per_lib = crate::core::config::get_output_dir_for_file(&file_uuid, state.db.pool()).await;
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
let output_dir = if std::path::Path::new(&per_lib).is_dir() {
per_lib
} else {
global_dir.to_string()
};
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
if !std::path::Path::new(&scenes_path).exists() {