diff --git a/src/queries/work_queue.rs b/src/queries/work_queue.rs index 21d5bb9..03a6e18 100644 --- a/src/queries/work_queue.rs +++ b/src/queries/work_queue.rs @@ -1,6 +1,6 @@ use chrono::Utc; -use sea_orm::*; use sea_orm::sea_query::Expr; +use sea_orm::*; use serde::Serialize; use crate::entities::work_queue::{ @@ -125,7 +125,10 @@ pub async fn reset_stale_running(db: &DatabaseConnection) -> DbResult { work_queue::Column::Status, Expr::value(WorkQueueStatus::Pending), ) - .col_expr(work_queue::Column::StartedAt, Expr::value(Option::::None)) + .col_expr( + work_queue::Column::StartedAt, + Expr::value(Option::::None), + ) .filter(work_queue::Column::Status.eq(WorkQueueStatus::Running)) .exec(db) .await?; @@ -172,10 +175,30 @@ pub async fn counts_all(db: &DatabaseConnection) -> DbResult { let items = WorkQueue::find().all(db).await?; let mut result = AllCounts { - download: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 }, - index: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 }, - tag: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 }, - organize: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 }, + download: TypeCounts { + pending: 0, + running: 0, + completed: 0, + failed: 0, + }, + index: TypeCounts { + pending: 0, + running: 0, + completed: 0, + failed: 0, + }, + tag: TypeCounts { + pending: 0, + running: 0, + completed: 0, + failed: 0, + }, + organize: TypeCounts { + pending: 0, + running: 0, + completed: 0, + failed: 0, + }, }; for item in items { @@ -204,10 +227,7 @@ pub struct AllCounts { } /// Check if all items for a pipeline are completed. -pub async fn pipeline_is_complete( - db: &DatabaseConnection, - pipeline_id: &str, -) -> DbResult { +pub async fn pipeline_is_complete(db: &DatabaseConnection, pipeline_id: &str) -> DbResult { let incomplete = WorkQueue::find() .filter(work_queue::Column::PipelineId.eq(pipeline_id)) .filter(work_queue::Column::Status.ne(WorkQueueStatus::Completed))