mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 16:02:19 +00:00
add suspended flows to cli queues
This commit is contained in:
@@ -9987,6 +9987,8 @@ components:
|
||||
type: number
|
||||
aggregate_wait_time_ms:
|
||||
type: number
|
||||
suspend:
|
||||
type: number
|
||||
required:
|
||||
- id
|
||||
- running
|
||||
|
||||
@@ -1258,7 +1258,7 @@ pub fn list_queue_jobs_query(
|
||||
join_outstanding_wait_times: bool,
|
||||
tags: Option<Vec<&str>>,
|
||||
) -> SqlBuilder {
|
||||
let (limit, offset) = paginate(pagination);
|
||||
let (limit, offset) = paginate_without_limits(pagination);
|
||||
let mut sqlb = SqlBuilder::select_from("queue")
|
||||
.fields(fields)
|
||||
.order_by("created_at", lq.order_desc.unwrap_or(true))
|
||||
|
||||
@@ -82,6 +82,12 @@ pub fn paginate(pagination: Pagination) -> (usize, usize) {
|
||||
(per_page, offset)
|
||||
}
|
||||
|
||||
pub fn paginate_without_limits(pagination: Pagination) -> (usize, usize) {
|
||||
let per_page = pagination.per_page.unwrap_or(MAX_PER_PAGE);
|
||||
let offset = (pagination.page.unwrap_or(1).max(1) - 1) * per_page;
|
||||
(per_page, offset)
|
||||
}
|
||||
|
||||
pub async fn now_from_db<'c, E: sqlx::PgExecutor<'c>>(
|
||||
db: E,
|
||||
) -> Result<chrono::DateTime<chrono::Utc>> {
|
||||
|
||||
@@ -160,6 +160,7 @@ export type QueuedJob = {
|
||||
priority?: number;
|
||||
self_wait_time_ms?: number;
|
||||
aggregate_wait_time_ms?: number;
|
||||
suspend?: number;
|
||||
};
|
||||
|
||||
export type job_kind = 'script' | 'preview' | 'dependencies' | 'flowdependencies' | 'appdependencies' | 'flow' | 'flowpreview' | 'script_hub' | 'identity' | 'deploymentcallback' | 'singlescriptflow';
|
||||
|
||||
+10
-3
@@ -6,6 +6,7 @@ import { pickInstance } from "./instance.ts";
|
||||
type Data = {
|
||||
count: number;
|
||||
later: number;
|
||||
suspended: number;
|
||||
waiting: number;
|
||||
running: number;
|
||||
rps30s: string;
|
||||
@@ -29,6 +30,7 @@ function createRow(tag: string, data: Record<string, Data>) {
|
||||
waiting: 0,
|
||||
later: 0,
|
||||
running: 0,
|
||||
suspended: 0,
|
||||
rps30s: "",
|
||||
rps5min: "",
|
||||
rps30min: "",
|
||||
@@ -40,7 +42,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
|
||||
const activeInstance = await pickInstance(opts, true);
|
||||
if (activeInstance) {
|
||||
try {
|
||||
const queuedJobs = await wmill.listQueue({workspace: workspace ?? 'admins', allWorkspaces: workspace === undefined});
|
||||
const queuedJobs = await wmill.listQueue({workspace: workspace ?? 'admins', allWorkspaces: workspace === undefined, perPage: 100000});
|
||||
const jobCounts30s = await wmill.countJobsByTag({
|
||||
horizonSecs: 30,
|
||||
workspaceId: workspace,
|
||||
@@ -68,7 +70,11 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
|
||||
createRow(job.tag, data);
|
||||
const scheduledFor = new Date(job.scheduled_for ?? "");
|
||||
if (job.running) {
|
||||
data[job.tag].running += 1;
|
||||
if (job.suspend) {
|
||||
data[job.tag].suspended += 1;
|
||||
} else {
|
||||
data[job.tag].running += 1;
|
||||
}
|
||||
} else if (scheduledFor <= nowFromDb) {
|
||||
data[job.tag].waiting += 1;
|
||||
} else {
|
||||
@@ -104,6 +110,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
|
||||
"Running",
|
||||
"Waiting",
|
||||
"Later",
|
||||
"Suspended",
|
||||
"RPS (30s)",
|
||||
"RPS (5min)",
|
||||
"RPS (30min)",
|
||||
@@ -111,7 +118,7 @@ async function displayQueues(opts: GlobalOptions, workspace?: string) {
|
||||
]);
|
||||
let body = []
|
||||
for (const tag in data) {
|
||||
body.push([tag, data[tag].running, data[tag].waiting, data[tag].later, data[tag].rps30s, data[tag].rps5min, data[tag].rps30min, data[tag].rps24h]);
|
||||
body.push([tag, data[tag].running, data[tag].waiting, data[tag].later, data[tag].suspended, data[tag].rps30s, data[tag].rps5min, data[tag].rps30min, data[tag].rps24h]);
|
||||
}
|
||||
table.body(body).render();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user