feat: trace-level matching, health watcher/worker status, timezone config

This commit is contained in:
Accusys
2026-05-21 01:08:30 +08:00
parent 8ede4be159
commit bebaa743ed
60 changed files with 6110 additions and 1586 deletions
+26 -14
View File
@@ -56,19 +56,25 @@ impl IngestionService {
.to_string();
// 1. Compute SHA256 for dedup
let content_hash = crate::core::storage::content_hash::compute_sha256(&canonical_path).ok().unwrap_or_default();
let content_hash = crate::core::storage::content_hash::compute_sha256(&canonical_path)
.ok()
.unwrap_or_default();
// 2. Hash check — same content = already registered
let videos_table = schema::table_name("videos");
if !content_hash.is_empty() {
if let Ok(Some(existing_uuid)) = sqlx::query_scalar::<_, String>(
&format!("SELECT file_uuid FROM {} WHERE content_hash = $1 LIMIT 1", videos_table)
)
if let Ok(Some(existing_uuid)) = sqlx::query_scalar::<_, String>(&format!(
"SELECT file_uuid FROM {} WHERE content_hash = $1 LIMIT 1",
videos_table
))
.bind(&content_hash)
.fetch_optional(self.db.pool())
.await
{
info!("Content already registered: {} ({})", filename, existing_uuid);
info!(
"Content already registered: {} ({})",
filename, existing_uuid
);
return Ok(Some(existing_uuid));
}
}
@@ -108,7 +114,8 @@ impl IngestionService {
let probe_result = probe::probe_video(file_path).ok();
let file_meta = std::fs::metadata(&canonical_path).ok();
let duration = probe_result.as_ref()
let duration = probe_result
.as_ref()
.and_then(|r| r.format.duration.as_ref())
.and_then(|s| s.parse::<f64>().ok())
.unwrap_or(0.0);
@@ -148,7 +155,11 @@ impl IngestionService {
}
let total_frames = {
let video_stream = probe_result.as_ref().and_then(|pr| pr.streams.iter().find(|s| s.codec_type.as_deref() == Some("video")));
let video_stream = probe_result.as_ref().and_then(|pr| {
pr.streams
.iter()
.find(|s| s.codec_type.as_deref() == Some("video"))
});
if let Some(stream) = video_stream {
if let Some(nb_frames_str) = &stream.nb_frames {
@@ -223,11 +234,14 @@ impl IngestionService {
// Store content_hash for dedup
if !content_hash.is_empty() {
let vt = schema::table_name("videos");
let _ = sqlx::query(&format!("UPDATE {} SET content_hash = $1 WHERE file_uuid = $2", vt))
.bind(&content_hash)
.bind(&uuid)
.execute(self.db.pool())
.await;
let _ = sqlx::query(&format!(
"UPDATE {} SET content_hash = $1 WHERE file_uuid = $2",
vt
))
.bind(&content_hash)
.bind(&uuid)
.execute(self.db.pool())
.await;
}
self.db
@@ -243,5 +257,3 @@ impl IngestionService {
Ok(Some(uuid))
}
}