fix: scan.rs stats API 使用 per-library 路徑 — 修復 Scene VLM 數量不顯示
- 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:
+32
-9
@@ -544,11 +544,14 @@ async fn get_ingestion_status(
|
|||||||
let identity_count = identity_ids.len() as i64;
|
let identity_count = identity_ids.len() as i64;
|
||||||
let strangers = stranger_traces.len() as i64;
|
let strangers = stranger_traces.len() as i64;
|
||||||
|
|
||||||
let scene_meta_path = format!(
|
let per_lib_dir = crate::core::config::get_output_dir_for_file(&file_uuid, pool).await;
|
||||||
"{}/{}.scene_meta.json",
|
let global_dir = crate::core::config::OUTPUT_DIR.as_str();
|
||||||
crate::core::config::OUTPUT_DIR.as_str(),
|
let scene_meta_base = if std::path::Path::new(&per_lib_dir).is_dir() {
|
||||||
file_uuid
|
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();
|
let scene_meta_ok = std::path::Path::new(&scene_meta_path).exists();
|
||||||
|
|
||||||
macro_rules! count_sql {
|
macro_rules! count_sql {
|
||||||
@@ -1153,8 +1156,15 @@ async fn get_file_stats_inner(
|
|||||||
..Default::default()
|
..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
|
// 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_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid);
|
||||||
let face_clusters = if std::path::Path::new(&face_cluster_path).exists() {
|
let face_clusters = if std::path::Path::new(&face_cluster_path).exists() {
|
||||||
if let Ok(content) = std::fs::read_to_string(&face_cluster_path) {
|
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>,
|
State(state): State<AppState>,
|
||||||
Path(file_uuid): Path<String>,
|
Path(file_uuid): Path<String>,
|
||||||
) -> Result<Json<crate::core::progress::PipelineProgress>, StatusCode> {
|
) -> 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
|
// 1. Try to read existing progress from Redis first
|
||||||
let redis_progress: Option<crate::core::progress::PipelineProgress> = {
|
let redis_progress: Option<crate::core::progress::PipelineProgress> = {
|
||||||
use crate::core::db::RedisClient;
|
use crate::core::db::RedisClient;
|
||||||
@@ -1521,7 +1540,6 @@ async fn get_pipeline_progress_handler(
|
|||||||
|
|
||||||
|
|
||||||
// Check scene_vlm progress from scenes.json
|
// 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);
|
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
|
||||||
if std::path::Path::new(&scenes_path).exists() {
|
if std::path::Path::new(&scenes_path).exists() {
|
||||||
if let Ok(scenes_json) = std::fs::read_to_string(&scenes_path) {
|
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
|
// Check face dedup from actual face_cluster.json content
|
||||||
// Always check if processors_done, regardless of tkg_node_count (A-10 fix)
|
// Always check if processors_done, regardless of tkg_node_count (A-10 fix)
|
||||||
if processors_done {
|
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);
|
let face_cluster_path = format!("{}/{}.face_cluster.json", output_dir, file_uuid);
|
||||||
if std::path::Path::new(&face_cluster_path).exists() {
|
if std::path::Path::new(&face_cluster_path).exists() {
|
||||||
if let Ok(content) = std::fs::read_to_string(&face_cluster_path) {
|
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>,
|
State(state): State<AppState>,
|
||||||
Path(file_uuid): Path<String>,
|
Path(file_uuid): Path<String>,
|
||||||
) -> Result<Json<SceneVlmStats>, StatusCode> {
|
) -> 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);
|
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
|
||||||
|
|
||||||
if !std::path::Path::new(&scenes_path).exists() {
|
if !std::path::Path::new(&scenes_path).exists() {
|
||||||
|
|||||||
Reference in New Issue
Block a user