fix: POST /api/v1/jobs 500 — wrong column names + NULL file_name
This commit is contained in:
@@ -426,7 +426,7 @@ async fn get_progress(file_uuid: Path<String>) -> Result<Json<ProgressResponse>,
|
||||
}))
|
||||
}
|
||||
|
||||
async fn list_jobs(Query(params): Query<JobsQuery>) -> Result<Json<JobListResponse>, StatusCode> {
|
||||
async fn list_jobs(Json(params): Json<JobsQuery>) -> Result<Json<JobListResponse>, StatusCode> {
|
||||
let pg = PostgresDb::init()
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
@@ -452,7 +452,7 @@ async fn list_jobs(Query(params): Query<JobsQuery>) -> Result<Json<JobListRespon
|
||||
|
||||
let jobs: Vec<(i32, String, String, String, String, Option<String>, i32, i32)> =
|
||||
sqlx::query_as(&format!(
|
||||
"SELECT j.id::int, j.uuid, v.file_name, COALESCE(j.status, 'QUEUED'), COALESCE(j.current_processor, ''), v.file_uuid, COALESCE(j.processed_frames, 0), COALESCE(j.total_frames, 0) \
|
||||
"SELECT j.id::int, j.uuid, COALESCE(v.file_name, ''), COALESCE(j.status, 'QUEUED'), COALESCE(j.current_processor, ''), v.file_uuid, COALESCE(j.progress_current, 0), COALESCE(j.progress_total, 0) \
|
||||
FROM {} j LEFT JOIN {} v ON v.file_uuid = j.uuid{} \
|
||||
ORDER BY j.id DESC LIMIT $1 OFFSET $2",
|
||||
jobs_table, videos_table, where_clause
|
||||
@@ -497,7 +497,7 @@ async fn get_job(Path(uuid): Path<String>) -> Result<Json<JobDetailResponse>, St
|
||||
let job: Option<(i32, String, String, String, Option<String>, i32, i32, String, Option<String>, Option<String>)> =
|
||||
sqlx::query_as(&format!(
|
||||
"SELECT j.id::int, j.uuid, COALESCE(v.file_name, 'unknown'), COALESCE(j.status, 'QUEUED'), j.current_processor, \
|
||||
COALESCE(j.processed_frames, 0), COALESCE(j.total_frames, 0), \
|
||||
COALESCE(j.progress_current, 0), COALESCE(j.progress_total, 0), \
|
||||
COALESCE(j.created_at::text, ''), j.started_at::text, j.updated_at::text \
|
||||
FROM {} j LEFT JOIN {} v ON v.file_uuid = j.uuid WHERE j.uuid = $1",
|
||||
jobs_table, videos_table
|
||||
|
||||
Reference in New Issue
Block a user