refactor: remove all dev.* and public.* schema hardcodes from runtime code

14 files updated to use schema::table_name() instead of hardcoded schema
prefixes. Only src/bin/release.rs intentionally retains dev.* references.
This commit is contained in:
Accusys
2026-05-14 14:40:14 +08:00
parent 261d134fee
commit 301a95e2bc
14 changed files with 184 additions and 139 deletions

View File

@@ -12,7 +12,7 @@ use crate::core::chunk::{rule1_ingest, rule3_ingest};
use crate::core::config::OUTPUT_DIR;
use crate::core::db::qdrant_db::QdrantDb;
use crate::core::db::{
MonitorJobStatus, PostgresDb, ProcessorJobStatus, RedisClient, VectorPayload, VideoStatus,
schema, MonitorJobStatus, PostgresDb, ProcessorJobStatus, RedisClient, VectorPayload, VideoStatus,
};
use crate::core::embedding::Embedder;
use crate::worker::config::WorkerConfig;
@@ -67,13 +67,15 @@ impl JobWorker {
self.processor_pool.sweep_stale().await;
// Reset stale running jobs: jobs stuck in 'running' with no active processor results
let monitor_jobs_table = schema::table_name("monitor_jobs");
let processor_results_table = schema::table_name("processor_results");
if let Err(e) = sqlx::query(
"UPDATE dev.monitor_jobs SET status = 'pending', updated_at = NOW()
&format!("UPDATE {} SET status = 'pending', updated_at = NOW()
WHERE status = 'running'
AND id NOT IN (
SELECT DISTINCT job_id FROM dev.processor_results
SELECT DISTINCT job_id FROM {}
WHERE status IN ('pending', 'running')
)",
)", monitor_jobs_table, processor_results_table),
)
.execute(self.db.pool())
.await
@@ -1022,8 +1024,9 @@ impl JobWorker {
let qdrant = QdrantDb::new();
let pool = db.pool();
let chunk_table = schema::table_name("chunk");
let rows = sqlx::query_as::<_, (String, String, String, f64, f64, String)>(
"SELECT chunk_id, chunk_type, text_content, start_time, end_time, content::text FROM dev.chunk WHERE file_uuid = $1 AND chunk_type = 'sentence' AND embedding IS NULL AND (text_content IS NOT NULL AND text_content != '') ORDER BY id",
&format!("SELECT chunk_id, chunk_type, text_content, start_time, end_time, content::text FROM {} WHERE file_uuid = $1 AND chunk_type = 'sentence' AND embedding IS NULL AND (text_content IS NOT NULL AND text_content != '') ORDER BY id", chunk_table),
)
.bind(uuid)
.fetch_all(pool)

View File

@@ -1079,8 +1079,9 @@ impl ProcessorPool {
"confidence": scene.confidence,
"top_5": scene.top_5,
});
let chunk_table = crate::core::db::schema::table_name("chunk");
let _ = sqlx::query(
"UPDATE dev.chunk SET metadata = metadata || $1::jsonb WHERE file_uuid=$2 AND chunk_id=$3"
&format!("UPDATE {} SET metadata = metadata || $1::jsonb WHERE file_uuid=$2 AND chunk_id=$3", chunk_table)
)
.bind(&meta)
.bind(uuid)