feat: Identity JSON sync + schema-aware column selection

- storage.rs: add local_profile field, check disk for profile.jpg
- tmdb_api.rs: trigger JSON sync after TMDb probe
- identity_api.rs: upload_profile_image triggers JSON sync
- identity_binding.rs: bind/unbind/merge trigger JSON sync
- get_identity_json: Lazy Sync (generates JSON from DB if missing)
- identities.rs + identity_api.rs: use schema-aware column selection (dev:name vs public:real_name)
- Fixes 500 errors on identities endpoints across schemas
This commit is contained in:
Accusys
2026-05-19 23:10:49 +08:00
parent 0eb08acaae
commit ba68cd2548
3 changed files with 21 additions and 14 deletions

View File

@@ -889,7 +889,7 @@ async fn search_identity_text(
let query = format!(
r#"SELECT c.file_uuid, c.chunk_id, c.start_time, c.end_time, c.text_content,
fd.identity_id, COALESCE(i.real_name, i.actor_name) AS identity_name, i.source AS identity_source,
fd.identity_id, CASE WHEN id_table LIKE 'dev.%' THEN i.name ELSE i.real_name END AS identity_name, i.source AS identity_source,
fd.trace_id
FROM {} c
LEFT JOIN {} fd ON fd.file_uuid = c.file_uuid
@@ -965,7 +965,7 @@ async fn search_identities_by_text(
let limit = params.limit.unwrap_or(50).min(100);
let query = format!(
r#"SELECT i.id::int, COALESCE(i.real_name, i.actor_name) AS name, i.source, i.tmdb_id,
r#"SELECT i.id::int, COALESCE(i.real_name, i.actor_name, i.name) AS name, i.source, i.tmdb_id,
fd.file_uuid, fd.trace_id,
c.chunk_id, c.start_time, c.text_content
FROM {} i
@@ -973,9 +973,9 @@ async fn search_identities_by_text(
JOIN {} c ON c.file_uuid = fd.file_uuid
AND c.start_time <= fd.frame_number / COALESCE(c.fps, 25.0)
AND c.end_time >= fd.frame_number / COALESCE(c.fps, 25.0)
WHERE COALESCE(i.real_name, i.actor_name) ILIKE $1
WHERE COALESCE(i.real_name, i.actor_name, i.name) ILIKE $1
AND ($2::text IS NULL OR fd.file_uuid = $2)
ORDER BY COALESCE(i.real_name, i.actor_name), c.start_time
ORDER BY COALESCE(i.real_name, i.actor_name, i.name), c.start_time
LIMIT $3"#,
id_table, fd_table, chunk_table
);