fix: M4 Phase 1 bugs - dev.chunks refs, search_path, uuid column
Bug fixes from M4 report: - 4 remaining dev.chunks → dev.chunk in SQL queries - search_path includes public for pgvector extension - get_chunk_by_chunk_id_and_uuid: uuid → file_uuid - New endpoint: GET /api/v1/file/:uuid/chunk/:chunk_id
This commit is contained in:
@@ -776,7 +776,7 @@ pub async fn run_5w1h_agent(db: &PostgresDb, file_uuid: &str) -> anyhow::Result<
|
||||
match embedder.embed_document(text).await {
|
||||
Ok(vector) => {
|
||||
if let Err(e) = sqlx::query(
|
||||
"UPDATE dev.chunks SET embedding = $1::vector WHERE chunk_id = $2 AND file_uuid = $3"
|
||||
"UPDATE dev.chunk SET embedding = $1::vector WHERE chunk_id = $2 AND file_uuid = $3"
|
||||
)
|
||||
.bind(&vector as &[f32])
|
||||
.bind(chunk_id)
|
||||
|
||||
@@ -1306,6 +1306,25 @@ async fn trigger_processing(
|
||||
})))
|
||||
}
|
||||
|
||||
async fn get_chunk_by_path(
|
||||
Path((file_uuid, chunk_id)): Path<(String, String)>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Chunk>, StatusCode> {
|
||||
let chunk = state
|
||||
.db
|
||||
.get_chunk_by_chunk_id_and_uuid(&chunk_id, &file_uuid)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
tracing::error!("[get_chunk_by_path] DB error: {}:{}", file_uuid, chunk_id);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?
|
||||
.ok_or_else(|| {
|
||||
tracing::warn!("[get_chunk_by_path] Not found: {}:{}", file_uuid, chunk_id);
|
||||
StatusCode::NOT_FOUND
|
||||
})?;
|
||||
Ok(Json(chunk))
|
||||
}
|
||||
|
||||
async fn get_asset_status(
|
||||
State(state): State<AppState>,
|
||||
Path(uuid): Path<String>,
|
||||
@@ -2508,6 +2527,7 @@ pub async fn start_server(host: &str, port: u16) -> anyhow::Result<()> {
|
||||
.route("/api/v1/files/scan", get(scan_files))
|
||||
.route("/api/v1/file/:file_uuid/probe", get(probe_by_uuid))
|
||||
.route("/api/v1/file/:file_uuid/process", post(trigger_processing))
|
||||
.route("/api/v1/file/:file_uuid/chunk/:chunk_id", get(get_chunk_by_path))
|
||||
|
||||
.route("/api/v1/progress/:uuid", get(get_progress))
|
||||
.route("/api/v1/jobs", get(list_jobs))
|
||||
|
||||
Reference in New Issue
Block a user