refactor(tkg): extract shared t() function to schema module

- Create src/core/db/schema.rs with t() and table_name() functions
- Remove duplicate t() from tkg.rs and trace_agent_api.rs
- postgres_db.rs uses schema::table_name() from shared module
This commit is contained in:
Accusys
2026-07-10 00:08:12 +08:00
parent 5a941f857c
commit 13abb15595
3 changed files with 103 additions and 70 deletions
+1 -8
View File
@@ -6,6 +6,7 @@ use std::path::Path;
use crate::core::db::postgres_db::PostgresDb;
use crate::core::db::redis_client::RedisClient;
use crate::core::db::schema::t;
use crate::core::progress::{publish_tkg_progress, TkgPhase, TkgProgress, TkgStats};
use std::sync::Arc;
@@ -121,14 +122,6 @@ async fn build_node_id_map(pool: &PgPool, file_uuid: &str) -> HashMap<(String, S
.collect()
}
fn t(name: &str) -> String {
let schema = std::env::var("DATABASE_SCHEMA").unwrap_or_else(|_| "dev".to_string());
if schema == "public" {
name.to_string()
} else {
format!("{}.{}", schema, name)
}
}
// ── Phase 0: Populate trace_id from face.json ───────────────────────────────────────────────────────