fix: tkg.rs avg_confidence moved before props construction + schema.rs ON CONFLICT backfill derived fields

- tkg.rs: avg_confidence calculation moved to line 1207 (before props json)
- tkg.rs: Added 'avg_confidence' to props json (round4)
- schema.rs: ON CONFLICT DO UPDATE expanded to backfill start_frame, end_frame,
  frame_count, key_frame, key_face, avg_confidence from tkg_nodes.properties

This fixes trace_profiles.avg_confidence always being NULL, and enables
automatic self-healing when upsert_trace_profile is called from any caller.
This commit is contained in:
Accusys
2026-08-07 14:04:54 +08:00
parent 64f5e3f543
commit cd8df324be
2 changed files with 15 additions and 7 deletions
+8 -1
View File
@@ -52,7 +52,14 @@ pub async fn upsert_trace_profile(
VALUES ($1, $2, $3, {sf}, {ef}, {fc}, {kf}, {kface}, 'pending', {avgc}, \
COALESCE($4::jsonb, {props_sub}, '{{}}'::jsonb)) \
ON CONFLICT (file_uuid, trace_id) \
DO UPDATE SET name = EXCLUDED.name{update_props}, updated_at = NOW()",
DO UPDATE SET name = EXCLUDED.name{update_props}, \
start_frame = EXCLUDED.start_frame, \
end_frame = EXCLUDED.end_frame, \
frame_count = EXCLUDED.frame_count, \
key_frame = EXCLUDED.key_frame, \
key_face = EXCLUDED.key_face, \
avg_confidence = EXCLUDED.avg_confidence, \
updated_at = NOW()",
sf = tkg_sub("(tn.properties->>'start_frame')::bigint"),
ef = tkg_sub("(tn.properties->>'end_frame')::bigint"),
fc = tkg_sub("(tn.properties->>'frame_count')::int"),