fix: pipeline timeline log, chunk lookup, face processor no fallback, Qdrant UUID script, delete safety rules
This commit is contained in:
@@ -2236,9 +2236,36 @@ impl PostgresDb {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn get_chunk_by_chunk_id_and_uuid(&self, chunk_id: &str, _uuid: &str) -> Result<Option<crate::core::chunk::types::Chunk>> {
|
||||
// Returns a minimal stub. The full Chunk struct is complex to reconstruct from DB.
|
||||
Ok(None)
|
||||
pub async fn get_chunk_by_chunk_id_and_uuid(&self, chunk_id: &str, uuid: &str) -> Result<Option<crate::core::chunk::types::Chunk>> {
|
||||
let table = schema::table_name("chunk");
|
||||
let row = sqlx::query_as::<_, (String, f64, f64, f64, String, Option<String>, Option<serde_json::Value>)>(
|
||||
&format!("SELECT chunk_type, start_time, end_time, fps, content::text, text_content, metadata FROM {} WHERE file_uuid = $1 AND chunk_id = $2 LIMIT 1", table)
|
||||
)
|
||||
.bind(uuid).bind(chunk_id)
|
||||
.fetch_optional(&self.pool).await?;
|
||||
|
||||
Ok(row.map(|(ct, st, et, fps, content_str, text_content, metadata)| {
|
||||
let content: serde_json::Value = serde_json::from_str(&content_str).unwrap_or_default();
|
||||
let chunk_type = match ct.as_str() {
|
||||
"time" => crate::core::chunk::types::ChunkType::TimeBased,
|
||||
"sentence" => crate::core::chunk::types::ChunkType::Sentence,
|
||||
"cut" => crate::core::chunk::types::ChunkType::Cut,
|
||||
"trace" => crate::core::chunk::types::ChunkType::Trace,
|
||||
"story" | "story_parent" | "story_child" => crate::core::chunk::types::ChunkType::Story,
|
||||
"visual" => crate::core::chunk::types::ChunkType::Visual,
|
||||
_ => crate::core::chunk::types::ChunkType::Story,
|
||||
};
|
||||
let start_frame = (st * fps).round() as i64;
|
||||
let end_frame = (et * fps).round() as i64;
|
||||
let mut c = crate::core::chunk::types::Chunk::new(
|
||||
0, uuid.to_string(), chunk_id.to_string(),
|
||||
chunk_type, crate::core::chunk::types::ChunkRule::Rule1,
|
||||
start_frame, end_frame, fps, content,
|
||||
);
|
||||
c.text_content = text_content;
|
||||
c.metadata = metadata;
|
||||
c
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn get_running_jobs_with_all_processors_done(&self, _limit: i32) -> Result<Vec<MonitorJob>> {
|
||||
@@ -2278,6 +2305,22 @@ impl PostgresDb {
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
fn write_pipeline_timeline(uuid: &str, processor: &str, status: &str) {
|
||||
let ts = chrono::Utc::now().to_rfc3339();
|
||||
let entry = serde_json::json!({
|
||||
"ts": ts,
|
||||
"file_uuid": uuid,
|
||||
"processor": processor,
|
||||
"status": status,
|
||||
});
|
||||
let path = std::path::Path::new(crate::core::config::OUTPUT_DIR.as_str())
|
||||
.join(format!("pipeline_{}.log", uuid));
|
||||
if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(&path) {
|
||||
use std::io::Write;
|
||||
let _ = writeln!(file, "{}", entry);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn upsert_processor_result(
|
||||
&self, job_id: i32, processor_type: crate::core::db::ProcessorType, uuid: &str, status: &str
|
||||
) -> Result<i32> {
|
||||
@@ -2291,6 +2334,9 @@ impl PostgresDb {
|
||||
))
|
||||
.bind(job_id).bind(ptype).bind(uuid).bind(status)
|
||||
.fetch_one(&self.pool).await?;
|
||||
|
||||
Self::write_pipeline_timeline(uuid, ptype, status);
|
||||
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user