feat: ASRX hybrid pipeline, identity history, worker fixes, checkpoint system
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
use bson::bson;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct IdentitySnapshot {
|
||||
id: i32,
|
||||
uuid: String,
|
||||
name: String,
|
||||
identity_type: Option<String>,
|
||||
source: Option<String>,
|
||||
status: String,
|
||||
tmdb_id: Option<i32>,
|
||||
tmdb_profile: Option<String>,
|
||||
metadata: serde_json::Value,
|
||||
#[serde(
|
||||
with = "bson::serde_helpers::chrono_datetime_as_bson_datetime_optional",
|
||||
default
|
||||
)]
|
||||
created_at: Option<DateTime<Utc>>,
|
||||
face_count: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct TargetIdentitySnapshot {
|
||||
id: i32,
|
||||
uuid: String,
|
||||
name: String,
|
||||
metadata_before: serde_json::Value,
|
||||
metadata_after: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct AliasEntry {
|
||||
name: String,
|
||||
locale: String,
|
||||
source: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct FacesTransferred {
|
||||
file_uuid: String,
|
||||
face_ids: Vec<String>,
|
||||
trace_ids: Vec<i32>,
|
||||
count: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct MergeParams {
|
||||
keep_history: bool,
|
||||
cleared_stranger_id: bool,
|
||||
performed_by_user: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
struct IdentityMergeHistory {
|
||||
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<bson::oid::ObjectId>,
|
||||
merge_id: String,
|
||||
source_identity: IdentitySnapshot,
|
||||
target_identity: TargetIdentitySnapshot,
|
||||
aliases_added_to_target: Vec<AliasEntry>,
|
||||
metadata_fields_added: Vec<String>,
|
||||
faces_transferred: FacesTransferred,
|
||||
merge_params: MergeParams,
|
||||
#[serde(with = "bson::serde_helpers::chrono_datetime_as_bson_datetime")]
|
||||
merged_at: DateTime<Utc>,
|
||||
#[serde(with = "bson::serde_helpers::chrono_datetime_as_bson_datetime")]
|
||||
undo_deadline: DateTime<Utc>,
|
||||
undone: bool,
|
||||
#[serde(
|
||||
with = "bson::serde_helpers::chrono_datetime_as_bson_datetime_optional",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
undone_at: Option<DateTime<Utc>>,
|
||||
undone_by: Option<String>,
|
||||
undone_snapshot: Option<serde_json::Value>,
|
||||
undo_expired: bool,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let doc = bson!({
|
||||
"merge_id": "test-id",
|
||||
"source_identity": {
|
||||
"id": bson::Bson::Int32(21),
|
||||
"uuid": "test-uuid",
|
||||
"name": "Test",
|
||||
"identity_type": "people",
|
||||
"source": "tmdb",
|
||||
"status": "confirmed",
|
||||
"tmdb_id": bson::Bson::Int32(123),
|
||||
"tmdb_profile": bson::Bson::Null,
|
||||
"metadata": {},
|
||||
"created_at": bson::Bson::DateTime(bson::DateTime::from_millis(1714641951963)),
|
||||
"face_count": bson::Bson::Int64(0)
|
||||
},
|
||||
"target_identity": {
|
||||
"id": bson::Bson::Int32(22),
|
||||
"uuid": "target-uuid",
|
||||
"name": "Target",
|
||||
"metadata_before": {},
|
||||
"metadata_after": bson::Bson::Null
|
||||
},
|
||||
"aliases_added_to_target": [],
|
||||
"metadata_fields_added": [],
|
||||
"faces_transferred": {
|
||||
"file_uuid": "",
|
||||
"face_ids": [],
|
||||
"trace_ids": [],
|
||||
"count": bson::Bson::Int64(0)
|
||||
},
|
||||
"merge_params": {
|
||||
"keep_history": false,
|
||||
"cleared_stranger_id": true,
|
||||
"performed_by_user": "0"
|
||||
},
|
||||
"merged_at": bson::Bson::DateTime(bson::DateTime::from_millis(1714641951963)),
|
||||
"undo_deadline": bson::Bson::DateTime(bson::DateTime::from_millis(1714641951963)),
|
||||
"undone": false,
|
||||
"undone_at": bson::Bson::Null,
|
||||
"undone_by": bson::Bson::Null,
|
||||
"undone_snapshot": bson::Bson::Null,
|
||||
"undo_expired": false
|
||||
});
|
||||
|
||||
let result: Result<IdentityMergeHistory, _> = bson::from_bson(doc);
|
||||
match result {
|
||||
Ok(h) => println!("Success! {:?}", h.merge_id),
|
||||
Err(e) => println!("Error: {}", e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user