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

@@ -8,7 +8,7 @@
//! - Object relationships
use crate::core::chunk::types::{Chunk, ChunkRule, ChunkType};
use crate::core::db::PostgresDb;
use crate::core::db::{schema, PostgresDb};
use anyhow::Result;
use serde_json::Value;
use std::collections::HashMap;
@@ -176,9 +176,10 @@ pub async fn search_visual_chunks(
/// Get all visual chunks for a video UUID
async fn get_visual_chunks_by_uuid(db: &PostgresDb, uuid: &str) -> Result<Vec<Chunk>> {
let chunk_table = schema::table_name("chunk");
let sql = format!(
"SELECT file_id, file_uuid, chunk_id, chunk_type, fps, start_frame, end_frame, text_content, content, metadata, vector_id, visual_stats FROM dev.chunk WHERE file_uuid = '{}' AND chunk_type = 'visual' ORDER BY start_frame ASC",
uuid.replace('\'', "''")
"SELECT file_id, file_uuid, chunk_id, chunk_type, fps, start_frame, end_frame, text_content, content, metadata, vector_id, visual_stats FROM {} WHERE file_uuid = '{}' AND chunk_type = 'visual' ORDER BY start_frame ASC",
chunk_table, uuid.replace('\'', "''")
);
let rows: Vec<(
@@ -373,6 +374,7 @@ pub async fn get_visual_chunk_statistics(
db: &PostgresDb,
uuid: &str,
) -> Result<HashMap<String, Value>> {
let chunk_table = schema::table_name("chunk");
let sql = format!(
"SELECT
COUNT(*) as total_chunks,
@@ -381,9 +383,10 @@ pub async fn get_visual_chunk_statistics(
MAX((content->'metadata'->>'avg_confidence')::float) as max_confidence,
SUM((content->'metadata'->>'object_count')::int) as total_objects,
AVG((content->'metadata'->>'spatial_density')::float) as avg_density
FROM dev.chunk
FROM {}
WHERE file_uuid = '{}'
AND chunk_type = 'visual'",
chunk_table,
uuid.replace('\'', "''")
);