fix: correct TKG node_type/edge_type mismatches in scan.rs and tkg.rs
Mismatches fixed (builder vs query layer): - 'text_region' -> 'text_trace' (3 locations: scan.rs count + tkg.rs LIP_SYNC query + tkg.rs LIP_SYNC node ID lookup) - 'yolo_object' -> 'object' (2 queries in scan.rs) - 'FACE_TO_FACE' -> CO_OCCURS_WITH + JOIN with tkg_nodes (2 queries in scan.rs, so face_face_edges correctly counts only face-track pairs) - 'HAND_OBJECT' -> 'hand_object' (2 queries in scan.rs) Impact: ingestion_status and file stats endpoints now return accurate counts; LIP_SYNC edges now resolve their target text nodes.
This commit is contained in:
+27
-7
@@ -542,10 +542,10 @@ async fn get_ingestion_status(
|
||||
let face_track_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'face_track'"));
|
||||
let gaze_track_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'gaze_track'"));
|
||||
let lip_track_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'lip_track'"));
|
||||
let text_region_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'text_region'"));
|
||||
let text_region_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'text_trace'"));
|
||||
let appearance_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'appearance_trace'"));
|
||||
let accessory_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'accessory'"));
|
||||
let object_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'yolo_object'"));
|
||||
let object_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'object'"));
|
||||
let hand_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'hand'"));
|
||||
let speaker_nodes: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_nodes_table} WHERE file_uuid = '{file_uuid}' AND node_type = 'speaker'"));
|
||||
|
||||
@@ -553,12 +553,20 @@ async fn get_ingestion_status(
|
||||
let tkg_edges_table = schema::table_name("tkg_edges");
|
||||
let co_occurrence_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'CO_OCCURS_WITH'"));
|
||||
let speaker_face_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'SPEAKS_AS'"));
|
||||
let face_face_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'FACE_TO_FACE'"));
|
||||
let face_face_edges: i64 = count_sql!(&format!(
|
||||
"SELECT COUNT(*) FROM {tkg_edges_table} e \
|
||||
INNER JOIN {tkg_nodes_table} sn ON e.source_node_id = sn.id \
|
||||
INNER JOIN {tkg_nodes_table} tn ON e.target_node_id = tn.id \
|
||||
WHERE e.file_uuid = '{file_uuid}' \
|
||||
AND e.edge_type = 'CO_OCCURS_WITH' \
|
||||
AND sn.node_type = 'face_track' \
|
||||
AND tn.node_type = 'face_track'"
|
||||
));
|
||||
let mutual_gaze_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'MUTUAL_GAZE'"));
|
||||
let lip_sync_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'LIP_SYNC'"));
|
||||
let has_appearance_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'HAS_APPEARANCE'"));
|
||||
let wears_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'WEARS'"));
|
||||
let hand_object_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'HAND_OBJECT'"));
|
||||
let hand_object_edges: i64 = count_sql!(&format!("SELECT COUNT(*) FROM {tkg_edges_table} WHERE file_uuid = '{file_uuid}' AND edge_type = 'hand_object'"));
|
||||
|
||||
// Rule 2 relationship chunks
|
||||
let rule2_chunks = count_sql!(&format!(
|
||||
@@ -994,19 +1002,31 @@ async fn get_file_stats(
|
||||
text_region_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "text_trace").await,
|
||||
appearance_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "appearance_trace").await,
|
||||
accessory_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "accessory").await,
|
||||
object_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "yolo_object").await,
|
||||
object_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "object").await,
|
||||
hand_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "hand").await,
|
||||
speaker_nodes: count_nodes(pool, &tkg_nodes_table, &file_uuid, "speaker").await,
|
||||
co_occurrence_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "CO_OCCURS_WITH")
|
||||
.await,
|
||||
speaker_face_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "SPEAKS_AS").await,
|
||||
face_face_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "FACE_TO_FACE").await,
|
||||
face_face_edges: sqlx::query_scalar::<_, i64>(&format!(
|
||||
"SELECT COUNT(*) FROM {tkg_edges_table} e \
|
||||
INNER JOIN {tkg_nodes_table} sn ON e.source_node_id = sn.id \
|
||||
INNER JOIN {tkg_nodes_table} tn ON e.target_node_id = tn.id \
|
||||
WHERE e.file_uuid = $1 \
|
||||
AND e.edge_type = 'CO_OCCURS_WITH' \
|
||||
AND sn.node_type = 'face_track' \
|
||||
AND tn.node_type = 'face_track'"
|
||||
))
|
||||
.bind(&file_uuid)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.unwrap_or(0),
|
||||
mutual_gaze_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "MUTUAL_GAZE").await,
|
||||
lip_sync_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "LIP_SYNC").await,
|
||||
has_appearance_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "HAS_APPEARANCE")
|
||||
.await,
|
||||
wears_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "WEARS").await,
|
||||
hand_object_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "HAND_OBJECT").await,
|
||||
hand_object_edges: count_edges(pool, &tkg_edges_table, &file_uuid, "hand_object").await,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use axum::{
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::core::db::PostgresDb;
|
||||
use crate::core::db::schema::t;
|
||||
use crate::core::db::PostgresDb;
|
||||
|
||||
pub fn trace_agent_routes() -> Router<crate::api::types::AppState> {
|
||||
Router::new()
|
||||
|
||||
Reference in New Issue
Block a user