Skip to main content

smriti/db/face_repo/
mod.rs

1//! Face database repository
2//!
3//! Handles all database operations for faces and face clusters.
4
5mod gallery;
6mod read;
7mod write;
8
9use rusqlite::Connection;
10
11use crate::ml::FaceEmbedding;
12
13#[derive(Debug, Clone)]
14pub struct GalleryEmbedding {
15    pub cluster_id: i64,
16    pub face_id: i64,
17    pub embedding: FaceEmbedding,
18}
19
20/// Face cluster record from database
21#[derive(Debug, Clone)]
22pub struct FaceClusterRecord {
23    pub id: i64,
24    pub name: Option<String>,
25    pub representative_face_id: Option<i64>,
26    pub photo_count: i64,
27    /// Path to the representative face thumbnail (computed, not stored in DB)
28    pub face_thumbnail_path: Option<String>,
29}
30
31/// A row from face_review_queue ready to be presented to the user.
32///
33/// Sample face ids are a small set of representative faces from the candidate
34/// cluster, used by the UI to show "here's the person we think this matches."
35#[derive(Debug, Clone)]
36pub struct ReviewItem {
37    pub queue_id: i64,
38    pub face_id: i64,
39    pub candidate_cluster_id: i64,
40    pub candidate_cluster_name: Option<String>,
41    pub candidate_cluster_size: i64,
42    pub candidate_sample_face_ids: Vec<i64>,
43    pub score: f32,
44}
45
46/// Face confirmation status filter for queries.
47#[derive(Debug, Clone)]
48pub enum FaceStatus {
49    Confirmed,
50    Unconfirmed,
51    All,
52}
53
54/// A face row with related metadata, used by face-list views.
55#[derive(Debug, Clone)]
56pub struct FaceDetail {
57    pub face_id: i64,
58    pub photo_id: i64,
59    pub cluster_id: Option<i64>,
60    pub confidence: f32,
61    pub user_confirmed: i32,
62}
63
64/// Face database repository
65pub struct FaceRepo<'a> {
66    pub(crate) conn: &'a Connection,
67}
68
69impl<'a> FaceRepo<'a> {
70    pub fn new(conn: &'a Connection) -> Self {
71        Self { conn }
72    }
73}