feat: add queued status + FIFO queue ordering

- Add Queued variant to VideoStatus enum
- Trigger sets videos.status='queued' instead of staying 'pending'
- Worker sets videos.status='processing' on pickup
- list_monitor_jobs_by_status ORDER BY created_at ASC (FIFO)
- queue_position counts both 'pending' and 'queued' jobs
This commit is contained in:
Accusys
2026-06-24 05:18:40 +08:00
parent 14e886cc08
commit 360cb991e1
6 changed files with 78 additions and 48 deletions
+4 -1
View File
@@ -194,6 +194,7 @@ pub enum VideoStatus {
Unregistered,
Registered,
Pending,
Queued,
Processing,
Processed,
Indexed,
@@ -208,6 +209,7 @@ impl VideoStatus {
VideoStatus::Unregistered => "unregistered",
VideoStatus::Registered => "registered",
VideoStatus::Pending => "pending",
VideoStatus::Queued => "queued",
VideoStatus::Processing => "processing",
VideoStatus::Processed => "processed",
VideoStatus::Indexed => "indexed",
@@ -222,6 +224,7 @@ impl VideoStatus {
"unregistered" => Some(VideoStatus::Unregistered),
"registered" => Some(VideoStatus::Registered),
"pending" => Some(VideoStatus::Pending),
"queued" => Some(VideoStatus::Queued),
"processing" => Some(VideoStatus::Processing),
"processed" => Some(VideoStatus::Processed),
"indexed" => Some(VideoStatus::Indexed),
@@ -2030,7 +2033,7 @@ sqlx::query(
&format!(
r#"
SELECT id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id
FROM {} WHERE status = $1 ORDER BY created_at DESC
FROM {} WHERE status = $1 ORDER BY created_at ASC
"#,
table
)