fix: type mismatch BIGINT->INT4 and FLOAT8->FLOAT4 in traces and faces endpoints
- trace_agent_api: CAST trace_id, frame_number to int; CAST confidence to float4 - identities: CAST frame_number to int; CAST confidence to float4 - Fixes 500 errors on /traces, /trace/:id/faces, /faces/candidates
This commit is contained in:
@@ -328,7 +328,7 @@ async fn list_face_candidates(
|
|||||||
|
|
||||||
let rows = if let Some(file_uuid) = &query.file_uuid {
|
let rows = if let Some(file_uuid) = &query.file_uuid {
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"SELECT id, face_id, file_uuid, frame_number, confidence,
|
"SELECT id, face_id, file_uuid, frame_number::int, confidence::float4,
|
||||||
jsonb_build_object('x', x, 'y', y, 'width', width, 'height', height) as bbox,
|
jsonb_build_object('x', x, 'y', y, 'width', width, 'height', height) as bbox,
|
||||||
NULL::jsonb as attributes
|
NULL::jsonb as attributes
|
||||||
FROM {}
|
FROM {}
|
||||||
@@ -366,7 +366,7 @@ async fn list_face_candidates(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let sql = format!(
|
let sql = format!(
|
||||||
"SELECT id, face_id, file_uuid, frame_number, confidence,
|
"SELECT id, face_id, file_uuid, frame_number::int, confidence::float4,
|
||||||
jsonb_build_object('x', x, 'y', y, 'width', width, 'height', height) as bbox,
|
jsonb_build_object('x', x, 'y', y, 'width', width, 'height', height) as bbox,
|
||||||
NULL::jsonb as attributes
|
NULL::jsonb as attributes
|
||||||
FROM {}
|
FROM {}
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ async fn list_traces_sorted(
|
|||||||
|
|
||||||
let query = format!(
|
let query = format!(
|
||||||
"SELECT tt.*, fd.id AS sample_face_id FROM (
|
"SELECT tt.*, fd.id AS sample_face_id FROM (
|
||||||
SELECT trace_id,
|
SELECT trace_id::int AS trace_id,
|
||||||
COUNT(*) AS face_count,
|
COUNT(*) AS face_count,
|
||||||
MIN(frame_number) AS start_frame,
|
MIN(frame_number)::int AS start_frame,
|
||||||
MAX(frame_number) AS end_frame,
|
MAX(frame_number)::int AS end_frame,
|
||||||
(MAX(frame_number) - MIN(frame_number))::float8 AS duration_sec,
|
(MAX(frame_number) - MIN(frame_number))::float8 AS duration_sec,
|
||||||
AVG(confidence)::float8 AS avg_confidence
|
AVG(confidence)::float8 AS avg_confidence
|
||||||
FROM {}
|
FROM {}
|
||||||
@@ -248,7 +248,7 @@ async fn list_trace_faces(
|
|||||||
Option<i32>,
|
Option<i32>,
|
||||||
f32,
|
f32,
|
||||||
)> = sqlx::query_as(
|
)> = sqlx::query_as(
|
||||||
&format!("SELECT id, frame_number, x, y, width, height, confidence \
|
&format!("SELECT id, frame_number::int, x, y, width, height, confidence::float4 \
|
||||||
FROM {} WHERE file_uuid = $1 AND trace_id = $2 \
|
FROM {} WHERE file_uuid = $1 AND trace_id = $2 \
|
||||||
ORDER BY frame_number ASC LIMIT $3 OFFSET $4",
|
ORDER BY frame_number ASC LIMIT $3 OFFSET $4",
|
||||||
crate::core::db::schema::table_name("face_detections"))
|
crate::core::db::schema::table_name("face_detections"))
|
||||||
|
|||||||
Reference in New Issue
Block a user