Fix AI reindex job execution and progress
Some checks failed
docker-images / resolve-build-targets (push) Failing after 1s
docker-images / build-and-push (admin) (push) Has been cancelled
docker-images / submit-indexnow (push) Has been cancelled
docker-images / build-and-push (backend) (push) Has been cancelled
docker-images / build-and-push (frontend) (push) Has been cancelled
ui-regression / playwright-regression (push) Has been cancelled
Some checks failed
docker-images / resolve-build-targets (push) Failing after 1s
docker-images / build-and-push (admin) (push) Has been cancelled
docker-images / submit-indexnow (push) Has been cancelled
docker-images / build-and-push (backend) (push) Has been cancelled
docker-images / build-and-push (frontend) (push) Has been cancelled
ui-regression / playwright-regression (push) Has been cancelled
This commit is contained in:
@@ -29,12 +29,24 @@ impl BackgroundWorker<AiReindexWorkerArgs> for AiReindexWorker {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match ai::rebuild_index(&self.ctx).await {
|
||||
match ai::rebuild_index(&self.ctx, Some(job_id)).await {
|
||||
Ok(summary) => {
|
||||
worker_jobs::mark_job_succeeded(
|
||||
&self.ctx,
|
||||
job_id,
|
||||
Some(serde_json::json!({
|
||||
"phase": "completed",
|
||||
"message": "AI 索引重建完成。",
|
||||
"progress": {
|
||||
"phase": "completed",
|
||||
"message": "AI 索引重建完成。",
|
||||
"total_chunks": summary.indexed_chunks,
|
||||
"processed_chunks": summary.indexed_chunks,
|
||||
"total_batches": summary.indexed_chunks.div_ceil(ai::REINDEX_EMBEDDING_BATCH_SIZE.max(1)),
|
||||
"current_batch": summary.indexed_chunks.div_ceil(ai::REINDEX_EMBEDDING_BATCH_SIZE.max(1)),
|
||||
"batch_size": ai::REINDEX_EMBEDDING_BATCH_SIZE.max(1),
|
||||
"percent": 100,
|
||||
},
|
||||
"indexed_chunks": summary.indexed_chunks,
|
||||
"last_indexed_at": summary.last_indexed_at.map(|value| value.to_rfc3339()),
|
||||
})),
|
||||
@@ -48,7 +60,7 @@ impl BackgroundWorker<AiReindexWorkerArgs> for AiReindexWorker {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ai::rebuild_index(&self.ctx).await?;
|
||||
ai::rebuild_index(&self.ctx, None).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user