diff --git a/backend/migrations/20240223231005_add_index_completed_job.down.sql b/backend/migrations/20240223231005_add_index_completed_job.down.sql new file mode 100644 index 0000000000..d2f607c5b8 --- /dev/null +++ b/backend/migrations/20240223231005_add_index_completed_job.down.sql @@ -0,0 +1 @@ +-- Add down migration script here diff --git a/backend/migrations/20240223231005_add_index_completed_job.up.sql b/backend/migrations/20240223231005_add_index_completed_job.up.sql new file mode 100644 index 0000000000..e8b52c0e81 --- /dev/null +++ b/backend/migrations/20240223231005_add_index_completed_job.up.sql @@ -0,0 +1,3 @@ +-- Add up migration script here +create index if not exists ix_completed_job_workspace_id_created_at +on completed_job(workspace_id, created_at desc, started_at desc, is_skipped, is_flow_step, job_kind); \ No newline at end of file diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index cb73848e7d..6f05f71e9a 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -5032,6 +5032,11 @@ paths: in: query schema: type: boolean + - name: has_null_parent + description: has null parent + in: query + schema: + type: boolean responses: "200": description: All completed jobs @@ -5076,6 +5081,11 @@ paths: in: query schema: type: boolean + - name: has_null_parent + description: has null parent + in: query + schema: + type: boolean - name: success description: filter on successful jobs in: query diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index dec0b74148..90b420bb01 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -666,6 +666,7 @@ pub struct ListQueueQuery { pub scheduled_for_before_now: Option, pub all_workspaces: Option, pub is_flow_step: Option, + pub has_null_parent: Option, } fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> SqlBuilder { @@ -712,6 +713,11 @@ fn list_queue_jobs_query(w_id: &str, lq: &ListQueueQuery, fields: &[&str]) -> Sq if let Some(fs) = &lq.is_flow_step { sqlb.and_where_eq("is_flow_step", fs); } + if let Some(fs) = &lq.has_null_parent { + if *fs { + sqlb.and_where_is_null("parent_job"); + } + } if let Some(dt) = &lq.created_before { sqlb.and_where_le("created_at", format!("to_timestamp({})", dt.timestamp())); @@ -992,6 +998,7 @@ async fn list_jobs( scheduled_for_before_now: lq.scheduled_for_before_now, all_workspaces: lq.all_workspaces, is_flow_step: lq.is_flow_step, + has_null_parent: lq.has_null_parent, }, &[ "'QueuedJob' as typ", @@ -3225,6 +3232,11 @@ fn list_completed_jobs_query( if let Some(fs) = &lq.is_flow_step { sqlb.and_where_eq("is_flow_step", fs); } + if let Some(fs) = &lq.has_null_parent { + if *fs { + sqlb.and_where_is_null("parent_job"); + } + } if let Some(jk) = &lq.job_kinds { sqlb.and_where_in( "job_kind", @@ -3270,6 +3282,7 @@ pub struct ListCompletedQuery { pub tag: Option, pub scheduled_for_before_now: Option, pub all_workspaces: Option, + pub has_null_parent: Option, } async fn list_completed_jobs( diff --git a/frontend/src/lib/components/runs/JobLoader.svelte b/frontend/src/lib/components/runs/JobLoader.svelte index 323792b888..a4df49c44f 100644 --- a/frontend/src/lib/components/runs/JobLoader.svelte +++ b/frontend/src/lib/components/runs/JobLoader.svelte @@ -59,7 +59,7 @@ function computeJobKinds(jobKindsCat: string | undefined): string { if (jobKindsCat == 'all') { - return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW},${CompletedJob.job_kind.DEPENDENCIES},${CompletedJob.job_kind.FLOWDEPENDENCIES},${CompletedJob.job_kind.APPDEPENDENCIES},${CompletedJob.job_kind.PREVIEW},${CompletedJob.job_kind.FLOWPREVIEW},${CompletedJob.job_kind.SCRIPT_HUB},${CompletedJob.job_kind.DEPLOYMENTCALLBACK},${CompletedJob.job_kind.SINGLESCRIPTFLOW}` + return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW},${CompletedJob.job_kind.DEPENDENCIES},${CompletedJob.job_kind.FLOWDEPENDENCIES},${CompletedJob.job_kind.APPDEPENDENCIES}` } else if (jobKindsCat == 'dependencies') { return `${CompletedJob.job_kind.DEPENDENCIES},${CompletedJob.job_kind.FLOWDEPENDENCIES},${CompletedJob.job_kind.APPDEPENDENCIES}` } else if (jobKindsCat == 'previews') { @@ -67,7 +67,7 @@ } else if (jobKindsCat == 'deploymentcallbacks') { return `${CompletedJob.job_kind.DEPLOYMENTCALLBACK}` } else { - return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW},${CompletedJob.job_kind.SINGLESCRIPTFLOW}` + return `${CompletedJob.job_kind.SCRIPT},${CompletedJob.job_kind.FLOW}` } }