diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 82e58c5322d8f..d6ce16dcae68d 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -1254,13 +1254,16 @@ pub fn list_queue_jobs_query( w_id: &str, lq: &ListQueueQuery, fields: &[&str], + pagination: Pagination, join_outstanding_wait_times: bool, tags: Option>, ) -> SqlBuilder { + let (limit, offset) = paginate(pagination); let mut sqlb = SqlBuilder::select_from("queue") .fields(fields) .order_by("created_at", lq.order_desc.unwrap_or(true)) - .limit(1000) + .limit(limit) + .offset(offset) .clone(); if let Some(tags) = tags { @@ -1273,6 +1276,7 @@ pub fn list_queue_jobs_query( #[derive(Serialize, FromRow)] struct ListableQueuedJob { pub id: Uuid, + pub running: bool, pub created_by: String, pub created_at: chrono::DateTime, pub started_at: Option>, @@ -1295,6 +1299,7 @@ async fn list_queue_jobs( authed: ApiAuthed, Extension(user_db): Extension, Path(w_id): Path, + Query(pagination): Query, Query(lq): Query, ) -> error::JsonResult> { let sql = list_queue_jobs_query( @@ -1302,6 +1307,7 @@ async fn list_queue_jobs( &lq, &[ "id", + "running", "created_by", "created_at", "started_at", @@ -1321,6 +1327,7 @@ async fn list_queue_jobs( "priority", "workspace_id", ], + pagination, false, get_scope_tags(&authed), ) @@ -1576,6 +1583,7 @@ async fn list_jobs( ) -> error::JsonResult> { check_scopes(&authed, || format!("jobs:listjobs"))?; + let limit = pagination.per_page.unwrap_or(1000); let (per_page, offset) = paginate(pagination); let lqc = lq.clone(); @@ -1607,6 +1615,7 @@ async fn list_jobs( &w_id, &ListQueueQuery { order_desc: Some(true), ..lq.into() }, UnifiedJob::queued_job_fields(), + Pagination { per_page: Some(limit), page: None }, true, get_scope_tags(&authed), ); diff --git a/backend/windmill-common/src/utils.rs b/backend/windmill-common/src/utils.rs index 8bbe541f07a28..97a68fe40562f 100644 --- a/backend/windmill-common/src/utils.rs +++ b/backend/windmill-common/src/utils.rs @@ -38,7 +38,7 @@ lazy_static::lazy_static! { .build().unwrap(); } -#[derive(Deserialize)] +#[derive(Deserialize, Clone)] pub struct Pagination { pub page: Option, pub per_page: Option,