refactor: cargo fmt across 27 files + behavioral fixes
Behavioral changes: - postgres_db: reorder default processors (cut first), prevent overwriting completed status - qdrant_db: fix scroll pagination exit condition (next.is_none()) - job_worker: add idempotency guards for face trace / TKG build; better error logging - main.rs: add LineWriter for stdout buffering Remaining diff is cargo fmt reformatting (line wrapping, import ordering).
This commit is contained in:
@@ -1325,7 +1325,8 @@ impl PostgresDb {
|
||||
.await?;
|
||||
|
||||
// ── TKG Operation Log ──
|
||||
sqlx::query("CREATE TABLE IF NOT EXISTS tkg_operation_log (
|
||||
sqlx::query(
|
||||
"CREATE TABLE IF NOT EXISTS tkg_operation_log (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
file_uuid VARCHAR(32) NOT NULL,
|
||||
operation VARCHAR(20) NOT NULL,
|
||||
@@ -1342,10 +1343,15 @@ impl PostgresDb {
|
||||
started_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
completed_at TIMESTAMPTZ,
|
||||
properties JSONB
|
||||
)").execute(pool).await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_tkg_op_file_uuid ON tkg_operation_log(file_uuid)")
|
||||
.execute(pool)
|
||||
.await?;
|
||||
)",
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"CREATE INDEX IF NOT EXISTS idx_tkg_op_file_uuid ON tkg_operation_log(file_uuid)",
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
// ── Functions & Triggers ──
|
||||
sqlx::query(
|
||||
@@ -1902,7 +1908,7 @@ impl PostgresDb {
|
||||
&format!(
|
||||
r#"
|
||||
INSERT INTO {} (uuid, video_path, status, video_id, processors)
|
||||
VALUES ($1, $2, 'pending', $3, ARRAY['asr','cut','ocr','face','face_cluster','pose','asrx'])
|
||||
VALUES ($1, $2, 'pending', $3, ARRAY['cut','asr','face','ocr','asrx','pose','appearance'])
|
||||
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id
|
||||
"#,
|
||||
jobs_table
|
||||
@@ -2775,7 +2781,8 @@ impl PostgresDb {
|
||||
)],
|
||||
) -> Result<()> {
|
||||
let table = schema::table_name("pre_chunks");
|
||||
self.delete_pre_chunks_by_processor(uuid, processor_type).await?;
|
||||
self.delete_pre_chunks_by_processor(uuid, processor_type)
|
||||
.await?;
|
||||
for (frame, ts, data, text, _) in chunks {
|
||||
sqlx::query(&format!(
|
||||
"INSERT INTO {} (file_uuid, processor_type, chunk_type, start_frame, start_time, data, text_content) \
|
||||
@@ -3127,13 +3134,23 @@ impl PostgresDb {
|
||||
let table = schema::table_name("videos");
|
||||
let key = processor.to_uppercase();
|
||||
let path = format!("{{progress,{}}}", key);
|
||||
let status_path = format!("{{progress,{},status}}", key);
|
||||
sqlx::query(&format!(
|
||||
"UPDATE {} SET processing_status = jsonb_set(COALESCE(processing_status, '{{}}'::jsonb), $1::text[], $2::jsonb) WHERE file_uuid = $3", table
|
||||
"UPDATE {} SET processing_status = \
|
||||
CASE \
|
||||
WHEN COALESCE(processing_status #>> $4::text[], '') = 'completed' \
|
||||
THEN processing_status \
|
||||
ELSE jsonb_set(COALESCE(processing_status, '{{}}'::jsonb), $1::text[], $2::jsonb) \
|
||||
END \
|
||||
WHERE file_uuid = $3",
|
||||
table
|
||||
))
|
||||
.bind(&path)
|
||||
.bind(serde_json::json!({"processed": current, "total": total, "status": status}))
|
||||
.bind(uuid)
|
||||
.execute(&self.pool).await?;
|
||||
.bind(&status_path)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -876,7 +876,7 @@ impl QdrantDb {
|
||||
.await?;
|
||||
let batch_len = batch.len();
|
||||
all_points.extend(batch);
|
||||
if batch_len < page_size {
|
||||
if batch_len < page_size || next.is_none() {
|
||||
break;
|
||||
}
|
||||
offset = next;
|
||||
|
||||
Reference in New Issue
Block a user