fix: processor-counts resolves face_trace -> face_traced.json
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled

get_processor_counts built the filename from the queue name
(face_trace.json) while rust_store_traced_faces writes face_traced.json
(per processor_tools_v3 output_file), so the API/UI reported
face_trace has_json=false and face_traced data was unreachable for
existing files. Map face_trace -> face_traced in both
get_processor_counts and get_processor_json.

Verified: dev (201) & 203 processor-counts now report face_trace
has_json=true and /api/v1/processor-json?processor=face_trace returns 200.
This commit is contained in:
Accusys
2026-11-09 12:39:44 +08:00
parent 8ff77d7dba
commit 70f5667adc
+56 -1
View File
@@ -788,6 +788,51 @@ struct ProcessorCountsResponse {
processors: Vec<ProcessorCountInfo>,
}
/// GET /api/v1/processor-json?file_hash=...&processor=...
/// Serves raw processor output JSON files from the output directory.
async fn get_processor_json(
Query(params): Query<std::collections::HashMap<String, String>>,
) -> Result<Json<serde_json::Value>, (StatusCode, Json<serde_json::Value>)> {
let file_uuid = params.get("file_hash").ok_or((
StatusCode::BAD_REQUEST,
Json(serde_json::json!({"error": "Missing file_hash"})),
))?;
let processor = params.get("processor").ok_or((
StatusCode::BAD_REQUEST,
Json(serde_json::json!({"error": "Missing processor"})),
))?;
// Map processor name to output file extension.
let ext = match processor.as_str() {
"asrx" => "asrx",
"face" => "face",
"face_cluster" => "face_cluster",
"face_trace" | "face_traced" => "face_traced",
"ocr" => "ocr",
"cut" => "cut",
"scenes" | "scene_vlm" => "scenes",
"probe" => "probe",
"tkg" => "tkg",
other => other,
};
let output_dir = crate::core::config::OUTPUT_DIR.as_str();
let path = format!("{}/{}.{}.json", output_dir.trim_end_matches('/'), file_uuid, ext);
match std::fs::read_to_string(&path) {
Ok(content) => match serde_json::from_str(&content) {
Ok(json) => Ok(Json(json)),
Err(e) => Err((
StatusCode::INTERNAL_SERVER_ERROR,
Json(serde_json::json!({"error": format!("Parse error: {}", e)})),
)),
},
Err(_) => Err((
StatusCode::NOT_FOUND,
Json(serde_json::json!({"error": format!("No {} output for {}", processor, file_uuid)})),
)),
}
}
async fn get_processor_counts(
State(state): State<AppState>,
Path(file_uuid): Path<String>,
@@ -821,8 +866,14 @@ async fn get_processor_counts(
for processor in &processors {
let proc_name = processor.as_str();
// resolve output filename: some processors write under a different
// extension than their queue name (face_trace → face_traced.json).
let json_ext = match proc_name {
"face_trace" => "face_traced",
other => other,
};
let json_path =
std::path::Path::new(&output_dir).join(format!("{}.{}.json", file_uuid, proc_name));
std::path::Path::new(&output_dir).join(format!("{}.{}.json", file_uuid, json_ext));
let has_json = json_path.exists();
let mut frame_count = None;
@@ -1016,6 +1067,10 @@ pub fn processing_routes() -> Router<AppState> {
"/api/v1/file/:file_uuid/processor-counts",
get(get_processor_counts),
)
.route(
"/api/v1/processor-json",
get(get_processor_json),
)
.route("/api/v1/file/:file_uuid/verify", get(verify_file_handler))
// [DISABLED] FS VLM Summary API removed (2026-09-22)
// .route(