feat: Implement face clustering and media retrieval for persons

This commit is contained in:
2025-11-15 23:39:51 +01:00
parent 0f3e098d6d
commit d444871829
9 changed files with 239 additions and 8 deletions

View File

@@ -58,4 +58,23 @@ impl FaceEmbeddingRepository for PostgresFaceEmbeddingRepository {
Ok(pg_embedding.map(FaceEmbedding::from))
}
async fn list_unassigned_by_user(&self, user_id: Uuid) -> CoreResult<Vec<FaceEmbedding>> {
let pg_embeddings = sqlx::query_as!(
PostgresFaceEmbedding,
r#"
SELECT fe.id, fe.face_region_id, fe.model_id, fe.embedding
FROM face_embeddings fe
JOIN face_regions fr ON fe.face_region_id = fr.id
JOIN media m ON fr.media_id = m.id
WHERE fr.person_id IS NULL AND m.owner_id = $1
"#,
user_id
)
.fetch_all(&self.pool)
.await
.map_err(|e| CoreError::Database(e.to_string()))?;
Ok(pg_embeddings.into_iter().map(FaceEmbedding::from).collect())
}
}