fix: add identity_uuid to /identities list + /file/:uuid/identities responses

This commit is contained in:
Accusys
2026-05-15 10:14:22 +08:00
parent fdcec82274
commit 37799fff4e
3 changed files with 11 additions and 6 deletions

View File

@@ -174,9 +174,9 @@ async fn list_identities(
}
};
let sql = "SELECT id, name, metadata FROM identities ORDER BY id DESC LIMIT $1 OFFSET $2";
let sql = "SELECT id, uuid, name, metadata FROM identities ORDER BY id DESC LIMIT $1 OFFSET $2";
let rows: Vec<(i32, String, Option<serde_json::Value>)> = match sqlx::query_as(sql)
let rows: Vec<(i32, uuid::Uuid, String, Option<serde_json::Value>)> = match sqlx::query_as(sql)
.bind(page_size as i64)
.bind(offset)
.fetch_all(db.pool())
@@ -195,8 +195,9 @@ async fn list_identities(
.into_iter()
.map(|r| IdentityResponse {
id: r.0,
name: r.1,
metadata: r.2,
identity_uuid: r.1.to_string(),
name: r.2,
metadata: r.3,
})
.collect();
@@ -245,6 +246,7 @@ pub struct FaceCandidatesResponse {
#[derive(Debug, Serialize)]
pub struct IdentityResponse {
pub id: i32,
pub identity_uuid: String,
pub name: String,
pub metadata: Option<serde_json::Value>,
}

View File

@@ -180,6 +180,7 @@ pub struct FileIdentitiesResponse {
#[derive(Debug, Serialize)]
pub struct FileIdentityItem {
pub identity_id: i32,
pub identity_uuid: Option<String>,
pub name: String,
pub metadata: serde_json::Value,
pub face_count: Option<i32>,
@@ -211,6 +212,7 @@ async fn get_file_identities(
.into_iter()
.map(|r| FileIdentityItem {
identity_id: r.identity_id,
identity_uuid: r.identity_uuid.map(|u| u.to_string()),
name: r.name,
metadata: r.metadata,
face_count: r.face_count,