fix: Qdrant collection name + PipelineProgress accumulation

- scan.rs: rule1 collection 'momentry_public_rule1_v2' → 'momentry_rule1'
- progress.rs: publish_pipeline_progress now reads existing progress and merges stages
This commit is contained in:
Accusys
2026-07-02 13:44:45 +08:00
parent 64f29d614b
commit 6507766ea2
2 changed files with 32 additions and 3 deletions

View File

@@ -801,7 +801,11 @@ async fn get_file_stats(
// Text chunk stats (rule1 collection)
let schema = std::env::var("DATABASE_SCHEMA").unwrap_or_else(|_| "dev".to_string());
let rule1_collection = format!("momentry_{}_rule1_v2", schema);
let rule1_collection = if schema == "public" {
"momentry_rule1".to_string()
} else {
format!("momentry_{}_rule1_v2", schema)
};
let text_filter = json!({
"must": [{"key": "file_uuid", "match": {"value": file_uuid}}]
});

View File

@@ -518,7 +518,7 @@ pub async fn get_progress(
}
}
/// Publish pipeline progress to Redis
/// Publish pipeline progress to Redis (accumulates with existing progress)
pub async fn publish_pipeline_progress(
redis: &RedisClient,
file_uuid: &str,
@@ -530,7 +530,32 @@ pub async fn publish_pipeline_progress(
file_uuid
);
if let Ok(mut conn) = redis.get_conn().await {
let json = serde_json::to_string(progress).unwrap_or_default();
// Try to read existing progress first
let existing: Option<PipelineProgress> = redis::cmd("GET")
.arg(&key)
.query_async(&mut conn)
.await
.ok()
.and_then(|s: String| serde_json::from_str(&s).ok());
let merged = if let Some(mut existing) = existing {
// Merge: update stages from new progress onto existing
for new_stage in &progress.stages {
if new_stage.status == "completed" || new_stage.progress > 0.0 {
if let Some(existing_stage) = existing.stages.iter_mut().find(|s| s.name == new_stage.name) {
existing_stage.status = new_stage.status.clone();
existing_stage.progress = new_stage.progress;
existing_stage.detail = new_stage.detail.clone();
}
}
}
existing.recalculate_overall();
existing
} else {
progress.clone()
};
let json = serde_json::to_string(&merged).unwrap_or_default();
let _: Result<(), _> = redis::cmd("SET")
.arg(&[&key, &json])
.query_async(&mut conn)