feat: trace_id i64→i32 fix, OCR search filter, Rule1 OCR trigger

- Fix trace_id SQL type mismatch: i64 → i32 in profile.rs structs and queries
- Add /ocr /asr /asrx search filter suffix to keyword/semantic/smart search
- Fix fetch_ocr_texts to handle both OCR data formats (string array + object array)
- Add has_ocr trigger for Rule1 chunk ingestion in job_worker.rs
- Add search_bm25 chunk_type filter parameter
- Fix single-frame video clip duration (0-frame → 1-frame minimum)
- Re-run Rule1 for 14 files with stuck OCR in pre_chunks
This commit is contained in:
Accusys
2026-07-30 19:34:35 +08:00
parent 5d0c771a2b
commit 85d5e1fe51
20 changed files with 1783 additions and 412 deletions
+37 -6
View File
@@ -1312,18 +1312,49 @@ impl ProcessorPool {
uuid: &str,
ocr_result: &OcrResult,
) -> Result<()> {
let frames_count = ocr_result.frames.len();
tracing::info!("Storing {} OCR pre-chunks for video {}", frames_count, uuid);
use crate::core::processor::ocr::{group_ocr_texts_by_zone_and_proximity, OcrGroup};
// Get frame height from videos table for Y-axis zone classification
let videos_table = crate::core::db::schema::table_name("videos");
let frame_height: Option<i32> = sqlx::query_scalar(&format!(
"SELECT height FROM {} WHERE file_uuid = $1",
videos_table
))
.bind(uuid)
.fetch_optional(db.pool())
.await?
.flatten();
let height = frame_height.unwrap_or(720) as f64; // Default fallback
// Group OCR texts by zone and proximity
let groups: Vec<OcrGroup> = group_ocr_texts_by_zone_and_proximity(&ocr_result.frames, height);
tracing::info!(
"Storing {} OCR groups (from {} frames) for video {}",
groups.len(),
ocr_result.frames.len(),
uuid
);
let mut pre_chunks_to_store = Vec::new();
for frame in ocr_result.frames.iter() {
for group in &groups {
let data = serde_json::json!({
"texts": frame.texts,
"timestamp": frame.timestamp,
"texts": group.texts,
"zone": group.zone.as_str(),
"start_frame": group.start_frame,
"end_frame": group.end_frame,
"timestamp": group.start_timestamp,
});
pre_chunks_to_store.push((frame.frame as i64, Some(frame.timestamp), data, None, None));
pre_chunks_to_store.push((
group.start_frame,
Some(group.start_timestamp),
data,
None,
None,
));
}
db.store_raw_pre_chunks_batch(uuid, "ocr", &pre_chunks_to_store)