Compare commits
1 Commits
d2b21789d3
...
a942c229ae
| Author | SHA1 | Date | |
|---|---|---|---|
| a942c229ae |
+30
-10
@@ -1,6 +1,6 @@
|
|||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use sea_orm::*;
|
|
||||||
use sea_orm::sea_query::Expr;
|
use sea_orm::sea_query::Expr;
|
||||||
|
use sea_orm::*;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::entities::work_queue::{
|
use crate::entities::work_queue::{
|
||||||
@@ -125,7 +125,10 @@ pub async fn reset_stale_running(db: &DatabaseConnection) -> DbResult<u64> {
|
|||||||
work_queue::Column::Status,
|
work_queue::Column::Status,
|
||||||
Expr::value(WorkQueueStatus::Pending),
|
Expr::value(WorkQueueStatus::Pending),
|
||||||
)
|
)
|
||||||
.col_expr(work_queue::Column::StartedAt, Expr::value(Option::<chrono::NaiveDateTime>::None))
|
.col_expr(
|
||||||
|
work_queue::Column::StartedAt,
|
||||||
|
Expr::value(Option::<chrono::NaiveDateTime>::None),
|
||||||
|
)
|
||||||
.filter(work_queue::Column::Status.eq(WorkQueueStatus::Running))
|
.filter(work_queue::Column::Status.eq(WorkQueueStatus::Running))
|
||||||
.exec(db)
|
.exec(db)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -172,10 +175,30 @@ pub async fn counts_all(db: &DatabaseConnection) -> DbResult<AllCounts> {
|
|||||||
let items = WorkQueue::find().all(db).await?;
|
let items = WorkQueue::find().all(db).await?;
|
||||||
|
|
||||||
let mut result = AllCounts {
|
let mut result = AllCounts {
|
||||||
download: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 },
|
download: TypeCounts {
|
||||||
index: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 },
|
pending: 0,
|
||||||
tag: TypeCounts { pending: 0, running: 0, completed: 0, failed: 0 },
|
running: 0,
|
||||||
organize: TypeCounts { pending: 0, running: 0, completed: 0, failed: 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 {
|
for item in items {
|
||||||
@@ -204,10 +227,7 @@ pub struct AllCounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Check if all items for a pipeline are completed.
|
/// Check if all items for a pipeline are completed.
|
||||||
pub async fn pipeline_is_complete(
|
pub async fn pipeline_is_complete(db: &DatabaseConnection, pipeline_id: &str) -> DbResult<bool> {
|
||||||
db: &DatabaseConnection,
|
|
||||||
pipeline_id: &str,
|
|
||||||
) -> DbResult<bool> {
|
|
||||||
let incomplete = WorkQueue::find()
|
let incomplete = WorkQueue::find()
|
||||||
.filter(work_queue::Column::PipelineId.eq(pipeline_id))
|
.filter(work_queue::Column::PipelineId.eq(pipeline_id))
|
||||||
.filter(work_queue::Column::Status.ne(WorkQueueStatus::Completed))
|
.filter(work_queue::Column::Status.ne(WorkQueueStatus::Completed))
|
||||||
|
|||||||
Reference in New Issue
Block a user