feat: update core API, database layer, and worker modules

- Remove unused imports (n8n_search, universal_search, Client, Arc, etc.)
- Update API endpoints for identity, face recognition, search
- Fix postgres_db.rs search_videos parent_uuid column
- Add snapshot API and identity agent API
- Clean up backup files (.bak, .bak2)
This commit is contained in:
Warren
2026-04-30 15:07:02 +08:00
parent 8f2208dd63
commit 2b23d1cfbd
148 changed files with 8553 additions and 48637 deletions

View File

@@ -41,9 +41,10 @@ pub mod sync_db;
pub use mongodb_db::MongoDb;
pub use postgres_db::{
Bm25Result, CandidateRecord, CreateApiKeyConfig, FileRecord, HybridSearchResult, MonitorJob,
MonitorJobStats, MonitorJobStatus, PostgresDb, ProcessorJobStatus, ProcessorResult,
ProcessorType, ResourceRecord, VideoRecord, VideoStatus,
Bm25Result, CandidateRecord, CreateApiKeyConfig, FileIdentityRecord, FileRecord,
HybridSearchResult, IdentityChunkRecord, IdentityDetailRecord, IdentityFaceRecord,
IdentityFileRecord, MonitorJob, MonitorJobStats, MonitorJobStatus, PostgresDb,
ProcessorJobStatus, ProcessorResult, ProcessorType, ResourceRecord, VideoRecord, VideoStatus,
};
pub use qdrant_db::{QdrantDb, VectorPayload};
pub use redis_client::{

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,8 @@ use std::sync::Arc;
use tokio::sync::RwLock;
use super::Database;
use crate::core::config;
use crate::core::storage::snapshot_manager::SnapshotTier;
pub struct RedisDb {
#[allow(dead_code)]
@@ -28,14 +30,20 @@ pub struct Job {
pub updated_at: String,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct SnapshotCacheEntry {
pub hits: u64,
pub last_access: i64,
pub status: String,
pub progress: Option<f32>,
}
impl RedisDb {
pub async fn push_job(&self, _job: &Job) -> Result<()> {
// TODO: Implement Redis client
Ok(())
}
pub async fn get_pending_jobs(&self) -> Result<Vec<Job>> {
// TODO: Implement Redis client
Ok(vec![])
}
@@ -45,14 +53,82 @@ impl RedisDb {
_status: &str,
_progress: f32,
) -> Result<()> {
// TODO: Implement Redis client
Ok(())
}
pub async fn publish_event(&self, _channel: &str, _message: &str) -> Result<()> {
// TODO: Implement Redis Pub/Sub
Ok(())
}
// --- Snapshot Cache Methods ---
pub async fn increment_snapshot_hits(&self, _file_uuid: &str) -> Result<u64> {
// TODO: Redis HINCRBY snapshot:hits:{uuid}
Ok(0)
}
pub async fn get_snapshot_hits(&self, _file_uuid: &str) -> Result<u64> {
// TODO: Redis GET snapshot:hits:{uuid}
Ok(0)
}
pub async fn update_last_access(&self, _file_uuid: &str) -> Result<()> {
// TODO: Redis SET snapshot:last_access:{uuid} = now EX 7d
Ok(())
}
pub async fn set_snapshot_status(
&self,
_file_uuid: &str,
status: &str,
progress: Option<f32>,
) -> Result<()> {
// TODO: Redis SET snapshot:status:{uuid} = {status, progress} EX 30m
let _ = (status, progress);
Ok(())
}
pub async fn get_snapshot_status(&self, _file_uuid: &str) -> Result<SnapshotCacheEntry> {
// TODO: Redis GET snapshot:status:{uuid}
Ok(SnapshotCacheEntry {
hits: 0,
last_access: 0,
status: "cold".to_string(),
progress: None,
})
}
pub async fn clear_snapshot_status(&self, _file_uuid: &str) -> Result<()> {
// TODO: Redis DEL snapshot:status:{uuid}
Ok(())
}
pub async fn set_migrate_hint(
&self,
_file_uuid: &str,
_parent_uuid: &str,
_count: u64,
) -> Result<()> {
// TODO: Redis SET snapshot:migrate_hint:{uuid}
Ok(())
}
pub async fn get_migrate_hint(&self, _file_uuid: &str) -> Result<Option<(String, u64)>> {
// TODO: Redis GET snapshot:migrate_hint:{uuid}
Ok(None)
}
pub fn compute_status_ttl(&self, tier: SnapshotTier) -> u64 {
match tier {
SnapshotTier::Hot => *config::snapshot::HOT_TTL_SECS,
SnapshotTier::Warm => *config::snapshot::WARM_TTL_SECS,
SnapshotTier::Cold => 0,
}
}
pub fn generating_timeout() -> u64 {
*config::snapshot::GENERATING_TIMEOUT_SECS
}
}
#[async_trait]

View File

@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
use serde_json::json;
use serde_json;
use crate::core::chunk::types::{Chunk, ChunkRule, ChunkType};
use crate::core::db::mongodb_db::MongoDb;
@@ -77,9 +77,9 @@ impl SyncDb {
let client = reqwest::Client::new();
let response = client
.post("http://localhost:11434/api/embeddings")
.json(&json!({
"model": "nomic-embed-text-v2-moe:latest",
"prompt": text
.json(&serde_json::json!({
"model": "all-minilm",
"prompt": text,
}))
.send()
.await
@@ -107,12 +107,21 @@ impl SyncDb {
for (i, segment) in asr_result.segments.iter().enumerate() {
let segment: &AsrSegment = segment;
let content = json!({
"text": segment.text,
"text_normalized": segment.text.to_lowercase(),
let content = serde_json::json!({
"rule": "rule1",
"data": {
"text": segment.text,
"start": segment.start,
"end": segment.end,
},
});
let metadata = json!({
let metadata = serde_json::json!({
"file_uuid": uuid,
"chunk_type": "sentence",
"chunk_rule": "rule1",
"fps": 0.0, // Will be set later
"start_frame": 0,
"end_frame": 0,
"language": asr_result.language,
"language_probability": asr_result.language_probability,
});