fix: trace debug cut query — use chunk table (no separate 'cut' table exists), show '-' when unavailable

This commit is contained in:
Accusys
2026-05-14 18:48:27 +08:00
parent 7fb6745c27
commit d2bc7c0e2d

View File

@@ -376,15 +376,15 @@ async fn trace_video(
} }
} }
// Query cut_id for this segment // Query cut/scene info from chunk table (not a separate "cut" table)
let cut_table = schema::table_name("cut"); let chunk_table = schema::table_name("chunk");
let cut_id: i32 = sqlx::query_scalar( let cut_label: String = sqlx::query_scalar::<_, String>(
&format!("SELECT scene_number FROM {} WHERE file_uuid = $1 AND start_frame <= $2 AND end_frame >= $2 LIMIT 1", cut_table) &format!("SELECT chunk_id FROM {} WHERE file_uuid = $1 AND chunk_type = 'cut' AND start_frame <= $2 AND end_frame >= $2 LIMIT 1", chunk_table)
) )
.bind(&file_uuid).bind(first_frame) .bind(&file_uuid).bind(first_frame)
.fetch_optional(state.db.pool()).await .fetch_optional(state.db.pool()).await
.unwrap_or(None) .unwrap_or(None)
.unwrap_or(0); .unwrap_or_else(|| "-".to_string());
// Sort traces for consistent ordering // Sort traces for consistent ordering
let mut sorted_traces: Vec<(i32, &Vec<i32>)> = trace_frames.iter().map(|(k, v)| (*k, v)).collect(); let mut sorted_traces: Vec<(i32, &Vec<i32>)> = trace_frames.iter().map(|(k, v)| (*k, v)).collect();
@@ -402,7 +402,7 @@ async fn trace_video(
"drawtext=text='Frame %{{n}} %{{pts}}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=12" "drawtext=text='Frame %{{n}} %{{pts}}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=12"
)); ));
parts.push(format!( parts.push(format!(
"drawtext=text='Cut\\: {}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=56", cut_id "drawtext=text='Cut\\: {}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=56", cut_label
)); ));
parts.push(format!( parts.push(format!(
"drawtext=text='{}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=100", file_uuid "drawtext=text='{}':fontsize=28:fontcolor=white:box=1:boxcolor=black@0.6:x=10:y=100", file_uuid